Noob to programming need help with a project
Hello, well as the title states im pretty new to programming, and I need help with a project I was given in class..
Code:
//preprocessor directives
#define _CRT_SECURE_NO_DEPRECATE
#include<stdio.h>
void display (int skateBd, int longBd, int scooter, int ripStick, int bicycle); //Funtion prototypes go here (minimum three user defined functions)
int MostInStock (int skateBd, int longBd, int scooter, int ripStick, int bicycle);
void restock (int skateBd, int longBd, int scooter, int ripStick, int bicycle);
int main ()
{
int skateBd; //declare 5 variables for the quantities of units (skateboard, longboard, etc.)
int longBd;
int scooter;
int ripStick;
int bicycle;
int id,qty;
skateBd =0; //initialize all 5 variables to 0
longBd =0;
scooter =0;
ripStick =0;
bicycle =0;
{
FILE *myPtr; //declare pointer to a file
myPtr=fopen("records.txt","r"); //connect to the file
fscanf(myPtr, "%d %d", &id, &qty); //get first pair of numbers from the file
while(id!=-9999)
{
printf("ID is %d, Qty is %d\n", id, qty); //print each pair of numbers on the screen
if (id==1) //do the comparisons witht the id here (use if/ese or switch)
{
skateBd=skateBd+qty;
}
else if (id==2)
{
longBd=longBd+qty;
}
else if (id==3)
{
scooter=scooter+qty;
}
else if (id==4)
{
ripStick=ripStick+qty;
}
else if (id==5)
{
bicycle=bicycle+qty;
}
fscanf(myPtr, "%d %d", &id, &qty); //get next pair of numbers from the file
}
fclose(myPtr); //close the file
}
//call display function
//call mostInStock function
//use if/else or switch here for return id from mostInstock
//call restock function
return 0;
}
//function definitions go here (minimum 3 user defined functions)
AS you can see I am not done with the bottem yet, only because when I run the program it triggers a Break. As I stated before I am new to this and have no idea whats wrong.
By now everyone is probly laughing at how easy this looks, but all I can ask is for some help.
Also my teacher gave me this and said to paste it where the source code is found so the file can be found easy.
I just saved it as "records.txt" on notepad and pasted it in the are where the source code was.
The records.txt file
PHP Code:
3 466
5 983
2 121
1 194
4 372
1 -193
5 -766
3 -458
4 -369
2 12
-9999
Once again I am a noob and if im not doing any thing right as for posting up something im VERY SORRY.