View Single Post
Old 05-11-2005, 11:47 PM   #3 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
Code:
05: #include <conio.h>
This is not a system independant header, and it is not needed in this program.
Code:
26:void main()
Please use int main(), it is more polite, any compiler will turn void main() in to int main() anyway..
Code:
33:  system("cls");
Tsk, tsk, tsk.. very not system independant to use a system call..
Code:
37:  fscanf(datain, "\n%s\n%s\n%d",prevCtry,prevTown);
Why search for 3 inputs and only use two, why reference the variables as parse by value, instead of the needed parse by reference..
Code:
44:              stotCtry = prevCtry+Ctry
how do you expect the char* to know anything about a + operator, your code is in C, yet you try and use varius C++ like features.
Code:
48: fscanf(datain, "\n%s\n%s\n%d", stotTown,stotCtry);
Again, you're one argument short, and you are trying to store strings (char*) into int types, another thing, when using the *scanf() functions, you have to be sure you've alocated the space needed, else your program will end up with unexplainable errors.
Code:
50:   if (strcmp(prevCtry) && strcmp(Ctry,"xxxx"))
51:           {
52:             NewCtryBreak();
53:           }
54:         else if (strcmp(prevTown) && strcmp(Town, "xxxx"))
You do realize strcmp() needs atleast two arguments.. both beeing const char* since we are picky here, it is better to use strncmp() since you're second argument is of a specific length.
Code:
62:  printf("\n\nGrandtotal = %d", gtotal);
gtotal was never declared, or calculated or anything...

Code:
81:  stotCtry = prevCtry+Ctry;
82:  strcpy(Ctry);
Again, prevCtry beeing of char* (and thats enough I dont even have to know what type Ctry is) has no refference of any + operator, and strcpy() needs two arguments, the storage pointer, and the intended filling to copy to it..
Code:
88:  stotTown = prevTown+Town;
89:  strcpy(Town);
Read my above description with sed 's/Ctry/Town/g'
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote