B
blackneos940
Guest
First, the Code:
Basically, it's a POS System, and I want it to Print whatever was entered..... The only problem is, it Prints it, but leaves off the first Letter..... For example, if I type "String", it will Print "tring"..... This is very odd..... :\ When I change the "getchar()" part to "while (1 == 1)" to test it, it comes out fine..... When I exit the Program.... Why is this.....? How can I make it Print out the Items without having to exit.....? I also want to be able to watch for a Character Input so that the Program knows if the User wants to stop adding items..... Thanks for any help guys.......
Code:
/*This is a rather Geeky POS System, which is Open Source. It is released under the GPL V2, or, at your option, any LATER Version. :)*/
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char item_input[200];
/*This is where the User enters the item to be checked out.*/
printf ("Enter Grocery Item Here:\n");
char* end_item_entry;
while (getchar() != 'q')
{
scanf ("%s\n", &item_input);
printf ("%s\n", item_input);
}
return 0;
}
Basically, it's a POS System, and I want it to Print whatever was entered..... The only problem is, it Prints it, but leaves off the first Letter..... For example, if I type "String", it will Print "tring"..... This is very odd..... :\ When I change the "getchar()" part to "while (1 == 1)" to test it, it comes out fine..... When I exit the Program.... Why is this.....? How can I make it Print out the Items without having to exit.....? I also want to be able to watch for a Character Input so that the Program knows if the User wants to stop adding items..... Thanks for any help guys.......