- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
printf("Enter item code: "); //Prompts user
scanf ("%14s", codenew1); //Read user input
len = strlen(codenew1); //Read each character into variable len
while (len != strspn(codenew1, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"))
{
printf ("Name contains non-alphabet characters. Try again!: "); //Prompts user to try again
scanf ("%14s", codenew1); //Reads user input
len = strlen(codenew1); //Read each character into variable len
} //Endwhile
strncpy(codenew, codenew1,2); //Copy the first two characters from the variable codenew1
codenew[2] = 0; //Store first two characters into variavle codenew
for ( j = 0; j < num_items; j++) //Loop for num_items times
{ //Beginning of for loop
if (strcmp(array[j].code1, codenew) == 0) //If codenew is found in file
{ //Beginning of if statement
price[i] = item_qty[i] * array[j].price1; //Calculating the price of an item
printf("Price : %d", price[i]); //Prints price
printf("\nEnter '%s' to confirm: ", array[j].itemname1); //Confirming the item
scanf("%19s", item_name1[i]);
while (strcmp(item_name1[i], array[j].itemname1 )!=0) //Looping until both item names are the same
{ //Begin while loop
printf("Item name is not %s ,Try Again!: ", array[j].itemname1); //Prompt user to try again
scanf ("%19s", item_name1[i]); //Reads item name into an array
len = strlen(item_name1[i]); //Reads each character into variable len
} //End while loop
len = strlen(item_name1[i]); //Read each character into variable len
while (len != strspn(item_name1[i], "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")) //While len contains non alphabetic characters
{ //Beginning while
printf ("Name contains non-alphabet characters. Try again!: "); //Prompts user to try again
scanf ("%19s", item_name1[i]); //Read user input
len = strlen(item_name1[i]); //Read each character into variable len
} //End while
strncpy(item_name[i], item_name1[i], 20); //Copy the first two characters from the variable codenew1
item_name[i][20] = 0; //Store first 20 characters in variable item_name[i]
total_price+= price[i]; //Calculate total price
break; //Terminates loop
} //End of if statement
else
if (strcmp(array[j].code1, codenew) != 0) //If codenew is found in file
{
printf("Invalid input! Try again.");
goto Here;
}
} //End of for loop