Alrighty...here's my problem...i have to get data entered from a user and insert it into a structure...i ask the user to give me a operation code (i = insert), i go to the insert function create my structure and ask the user for the data...but how do i store it into the structure ? can i try to store directly in scanf ?
thanks here's my code
Code:
#include <stdio.h>
int main()
{
char operCode;
printf("Enter operation code: ");
scanf("%c", &operCode);
if (operCode == 'i')
{
insertPart();
}
/*
if (operCode == 's')
{
searchPart();
}
if (operCode == 'u')
{
updatePart();
}
if (operCode == 'p')
{
printPart();
}
*/
if (operCode == 'q')
{
printf("Program Terminated !\n");
}
}
int insertPart()
{
int part = 0;
char name;
int quan = 0;
struct comp_part
{
int partNum;
char partName[15];
int quantity;
};
printf("Enter part number: ");
scanf("%i", &part);
printf("Enter part name: ");
scanf("%c", &name);
printf("Enter quantity on hand: ");
scanf("%i", &quan);
}