| | |
I need help please
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2007
Posts: 2
Reputation:
Solved Threads: 0
Dear Members
I have started the following program, and I do not know how to solve the issue to store names in an array and retrieve them again, and how tos tore the names in a file in the Hard drive. If somebody could help me with my issue. Thanks so much
Ahmed.
Source Code
I have started the following program, and I do not know how to solve the issue to store names in an array and retrieve them again, and how tos tore the names in a file in the Hard drive. If somebody could help me with my issue. Thanks so much
Ahmed.
Source Code
C++ Syntax (Toggle Plain Text)
#include <iostream.h> #include <string.h> #include <ctype.h> main() { float grade[25][2]={0,0,0};//first grade, second grade char studentsname[25][13];//students' names char name; int num =0; int test; char yesorno = 'y'; for (int i=0; i<5 ; i++) { cout<<"Enter name of student number "<<i+1<<'\n'; cin>>studentsname[i][]; for (int j=0; j<2; j++) { cout<<"Enter grade of test "<<j+1<<" for student "<<studentsname[i+1][13]<<" : "; cin>>grade[i][j]; cout<<'\n'; } } while (yesorno =='y') { cout<<"Enter a student's name : "; cin>>name; for (i=0; i<25; i++) { if (name == studentsname[i][13]) { cout<<"Which score woudl like to see 1 or 2 : "; cin>>test; cout<<'\n'; cout<<"student "<<name<<"] got "<<grade[num-1][13]<<" in test "<<test<<'\n'; cout<<"Would you like to continue : (y/n) ?\n"; cin>>yesorno ; } else cout<<"This student is not among the class "; } } return 0; }
Last edited by cscgal; Dec 18th, 2007 at 5:05 pm. Reason: Added code tags
Ok...firstly, u really should learn about <fstream>
Declaration:
#include <fstream>
..
...
//in your main()
ofstream fout;
fout.open("NEW.txt");
fout<<name; //this goes after user inputs @ after you stored students' names into -> name
..
...
..
//once done, close the file
fout.close();
Declaration:
#include <fstream>
..
...
//in your main()
ofstream fout;
fout.open("NEW.txt");
fout<<name; //this goes after user inputs @ after you stored students' names into -> name
..
...
..
//once done, close the file
fout.close();
Last edited by neosomosis; Dec 17th, 2007 at 3:37 pm. Reason: typo
![]() |
Other Threads in the C++ Forum
- Previous Thread: Word break and line break in Rich Edit Control
- Next Thread: Using arrays and menus...
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





