#include
#include
int main()
{
int bytes_read;
//int nbytes = 100;
size_t nbytes = 100;
char *my_string;
puts ("Please enter a line of text.");
/* These 2 lines are the heart of the program. */
my_string = (char *) malloc (nbytes + 1);
bytes_read = getline (&my_string, &nbytes, stdin);
if (bytes_read == -1)
{
puts ("ERROR!");
}
else
{
puts ("You typed:");
// This is how to read a line and print every letter.
int i=1;
while(i < bytes_read){
printf("%c\n",*my_string++);
i++;
}
}
return 0;
}
2010年7月1日 星期四
訂閱:
張貼留言 (Atom)
0 意見:
張貼留言