Hi, im doing homework in C programming, the programme is about "incourse assessment system".
Does anybody have similar example on the above topic, can you please help me. I need to see sample coding. Please.. urgent...
Hi, im doing homework in C programming, the programme is about "incourse assessment system".
Does anybody have similar example on the above topic, can you please help me. I need to see sample coding. Please.. urgent...
Last edited by elfreakz; 04-19-2005 at 08:55 AM.
the programme is main for lecturer to key in and view, the marks of any assessment of the student (test 1, assignment, and test 2). It is for 12 student only.
Post some code and we can help you, but we're not here to do your homework for you.Originally Posted by kermi3
[tag][/tag]Code:#include <stdio.h> #include <iostream.h> void test1(); void test1_marks(); void test1_view_marks(); void back_to_main_menu(); void main() { test1(); } void test1() { char choice; printf ("\n############################################\n"); printf ("\nTest 1\n"); printf ("\n############################################\n"); printf ("\n[1] Enter Marks\n[2] View Marks\n[3] Back to Main Menu\n\n\n"); printf ("You Choose:"); scanf ("choice"); if ( choice == '1') { test1_marks(); } else if ( choice == '2') { test1_view_marks(); } else if ( choice == '3') { back_to_main_menu(); } } void test1_marks() { struct studentData { char studentname [8]; int studentmark; }; { FILE *cfPtr; struct studentData blankClient = { "", 0, }; if (( cfPtr = fopen ("credit.dat", "r+")) == NULL ) printf ( "File could not be opened.\n"); else { printf ( "Enter Student Name\n?" ); fscanf ( stdin, "%s%s%slf", blankClient.studentname ); while ( blankClient.studentname != 0 ) { printf ( "Enter Student Mark:\n" ); fwrite ( &blankClient, sizeof (struct studentData), 1, cfPtr ); } fclose( cfPtr ); } } return 0; }
this is half of it. i seem dont understand anything.. gosh.. alot of errors...
scanf ("choice");
should be
scanf ("%c", &choice);
main()'s return type is int, not void
If you post your errors, it'll be easier for us to help you.
Linking...
TEST1.obj : error LNK2001: unresolved external symbol _back_to_main_menu
TEST1.obj : error LNK2001: unresolved external symbol _test1_view_marks
Debug/TEST1.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
TEST1.exe - 3 error(s), 0 warning(s)
i need to get TEST 1 screen to work, then TEST 2 and ASSIGNMENT screen will only need to change alil bit of TEST 1... hopefully someone can help me
You haven't defined
void test1_view_marks();
void back_to_main_menu();
If this is supposed to be pure C code, don't include <iostream.h>. If this assignment can be done in C++, then there are much easier ways to go about certain things.
And a void function doesn't return 0 or any other value. If you like, you can write a return statement like so:
return;
this code looks ok now.. but why when i choose 1, it suddently close?Code:#include <stdio.h> void test1(); void test1_marks(); void test1_view_marks(); void back_to_main_menu(); void main() { test1(); } void test1() { char choice; printf ("\n############################################\n"); printf ("\nTest 1\n"); printf ("\n############################################\n"); printf ("\n[1] Enter Marks\n[2] View Marks\n[3] Back to Main Menu\n\n\n"); printf ("You Choose:"); scanf ("choice"); if ( choice == '1') { test1_marks(); } else if ( choice == '2') { test1_view_marks(); } else if ( choice == '3') { back_to_main_menu(); } } void test1_marks() { struct studentData { char studentname [8]; int studentmark; }; FILE *cfPtr; struct studentData blankClient = { "", 0, }; if (( cfPtr = fopen ("credit.dat", "r+")) == NULL ) printf ( "File could not be opened.\n"); else { printf ( "Enter Student Name\n?" ); fscanf ( stdin, "%s%s%slf", blankClient.studentname ); while ( blankClient.studentname != 0 ) { printf ( "Enter Student Mark:\n" ); fwrite ( &blankClient, sizeof (struct studentData), 1, cfPtr ); } fclose( cfPtr ); } } void test1_view_marks() { } void back_to_main_menu() { }
you need to get input / make it pause to stop it suddenly quiting. Also I think theres an extra } at the end of void test1_marks()
Originally Posted by kzar
i dont get u clearly kzar
Show me the contents of the input file and I can try to fix it.
Pressure, the contents of the input file would look like:-
TEST 1
[1] Enter Marks --> will be link to another screen which will ask user to input 12 student ID and Marks, else back to TEST 1 screen.
[2] View Marks --> will view all marks else back to TEST 1 screen
[3] Back To Main Menu
-> i dont really know how to use database, i believe for this kind of question i need to use file processing and database right?
A couple of things:
I'm pretty sure you just want to get a string into studentname so you only need 1 "%s" format modifier.Code:fscanf ( stdin, "%s%s%slf", blankClient.studentname );
Also change the return value of main into an int not void - this has already been mentioned.
The program also exits because you failed to change the scanf("choice"); again this has already been mentioned earlier. You would want something like:
Please read the previous posts and make changes instead of just ignoring them.Code:scanf("%c",&choice);
The cost of software maintenance increases with the square of the programmer's creativity.
oh my god, that is so confuse!