This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

microblaze getchar() not functioning properly


Hi,

  getchar function is not working properly. An extra null character is
appended for each and every input character.

  Ex:
 #include<stdio.h>
int main()
{
    int i,j=0;
    char buf[10];
    xil_printf("main\n");
      while(j<6)
    {
    	i=getchar();
    	buf[j]=i;
    }
        xil_printf("%s\n",buf);
        return 0;
}


For the above program if i give input as:
stefen

Then it is printing on 's'

I tried to print variable 'j' after getchar() function in code. Then
for each character I enter 'j' value is incremented by two.

Thanks,
Nagaraju


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]