I am working on a program that prints "How are you?" on the screen by printing byte by byte.
First I wrote
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
putchar(72);
putchar(111);
putchar(119);
putchar(32);
putchar(97);
putchar(114);
putchar(101);
putchar(32);
putchar(121);
putchar(111);
putchar(117);
putchar(63);
return 0;
}
And the output was exactly what was expected.
Now I wrote
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
unsigned char t[20];
t[0]=72;
t[1]=111;
t[2]=119;
t[3]=32;
t[4]=97;
t[5]=114;
t[6]=101;
t[7]=32;
t[8]=121;
t[9]=111;
t[10]=117;
t[11]=63;
int i;
for(i=0;i<12;i++)
{
printf("%c",putchar(t[i]));
}
return 0;
}
and the output is: HHooww aarree yyoouu??
Why?
EDIT:
I have it, there should be just the
Code:
for(i=0;i<12;i++)
{
putchar(t[i]);
}