Sep 27, 2012 at 5:37am UTC
This is a part of my project. And I don't know why the "name" and the "namefind" don't match if I run it. Is the loop correct?
void ShopMoreTopsJackets()
{
FILE *List, *Items;
Items = fopen ("itemstikal.txt","r");
List = fopen ("Listikal.txt","w");
int quantity, price, YON;
char name[10], size[5], namefind[10];
printf ("\nWhat to buy? ");
scanf ("%s", &namefind);
fscanf (Items, "%s %d", &name, &price);
do
{
printf ("\nWhat size? (S, M, L): ");
scanf ("%s", &size);
printf ("\nHow many pieces? ");
scanf ("%d", &quantity);
fprintf (List, "%s %s %d %d %d\n", name, size, quantity, price, (quantity*price));
printf ("\nShop for more? tops 1-Yes, 2-No: ");
scanf ("%d",&YON);
if (YON==2)
{
printf ("\nBack to Menu? 1-Yes, 2-No: ");
scanf ("%d", &YON);
if (YON==1)
{
MENU();
}
else
{
FillUpForm();
}
}
else
{
ShopMoreTopsJackets();
}
}
while(name==namefind);
fclose (List);
fclose (Items);
getch();
}
Last edited on Sep 27, 2012 at 5:38am UTC
Sep 27, 2012 at 5:49am UTC
U cannot compare 2 char arrays like that. Try this with the <string.h> header:
while (!strcmp(name, namefind)); //if true
Sep 27, 2012 at 5:57am UTC
Thanks.
I've tried it already but there's still no output printed on the file. :(
Do you want me to show you my whole program? I'll appreciate it so much if you help me.
Sep 27, 2012 at 6:33pm UTC
Sure, if it's not too long. Don't forget code tags thankx XD