2010年7月1日 星期四

[ACM] 2007 tag checker - how to take a letter out


#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);

//Take particular letter out
printf("%c",my_string[2]);

if (bytes_read == -1)
{
puts ("ERROR!");
}
else
{
puts ("You typed:");
//puts (my_string);
int i=1;
while((i < bytes_read)&&(*my_string != '#')){
printf("%c\n",*my_string++);
i++;
}
}

return 0;
}

0 意見:

張貼留言