C++ Read in 'student record' information, print it out again.  | Banned | | Join Date: Aug 2007 Location: Lahore Pakistan
Posts: 929
| | |
Here is the question.
Write a program that will get a record of the student i.e. Name, Fathers Name, Degree Studying, Phone Number, and Date Of Birth and Then Show the record of the student?
Thanx
Don't go too much advance
I only know about cout,cin,if else, clrscr, getch statements.
Thanx
|  | Moderator | | Join Date: Mar 2007 Location: Hyderabad, India
Posts: 2,192
| | | re: C++ Read in 'student record' information, print it out again. Quote:
Originally Posted by Ali Rizwan Here is the question.
Write a program that will get a record of the student i.e. Name, Fathers Name, Degree Studying, Phone Number, and Date Of Birth and Then Show the record of the student?
Thanx
Don't go too much advance
I only know about cout,cin,if else, clrscr, getch statements.
Thanx Kindly POST what you have tried ?
And from which database you want to retrieve the data?
|  | Banned | | Join Date: Aug 2007 Location: Lahore Pakistan
Posts: 929
| | | re: C++ Read in 'student record' information, print it out again. Quote:
Originally Posted by amitpatel66 Kindly POST what you have tried ?
And from which database you want to retrieve the data? Actually amit there is no type of database we have just started C++ in university from 8 days.
ANd we have just learnd abbout cout, cin, clrscr, getch and some basics.
Thanx
|  | Moderator | | Join Date: Mar 2007 Location: Hyderabad, India
Posts: 2,192
| | | re: C++ Read in 'student record' information, print it out again. Quote:
Originally Posted by Ali Rizwan Actually amit there is no type of database we have just started C++ in university from 8 days.
ANd we have just learnd abbout cout, cin, clrscr, getch and some basics.
Thanx Oh ok. So you are just gonna accept the details from the user at run time and display it on the screen is it?
then it would be very simple. you could make a try to do this. We will help you out in case if you face any error!!
|  | Banned | | Join Date: Aug 2007 Location: Lahore Pakistan
Posts: 929
| | | re: C++ Read in 'student record' information, print it out again.
Hi all,
What is the problem with this code? -
#include<iostream.h>
-
#include<conio.h>
-
-
void main()
-
-
{
-
-
clrscr();
-
-
long char a,b,c,d,e;
-
-
cout<<"------------";
-
cout<<"\nStudent Form";
-
cout<<"\n------------";
-
-
cout<<"\n\n\n\n";
-
-
cout<<"Enter your Name : ";
-
cin>>a;
-
-
cout<<"\nEnter your Father's Name : ";
-
cin>>b;
-
-
cout<<"\nEnter your Degree : ";
-
cin>>c;
-
-
cout<<"\nEnter your Phone No. : ";
-
cin>>d;
-
-
cout<<"\nEnter your Date of Birth : ";
-
cin>>e;
-
-
-
getch();
-
-
}
There is no problem but when i input name "Ali" or any other output is this - Enter your Name : Ali
-
Enter your Father's Name :
-
Enter your Degree :
-
Enter your Phone No. :
-
Enter your Date of Birth :
But i enter only a single character like only A or any other it works right.
I m not understanding this.
Please help me
I have to submit it tommorow
Thanx
| | Member | | Join Date: Sep 2007
Posts: 90
| | | re: C++ Read in 'student record' information, print it out again. Quote:
Originally Posted by Ali Rizwan Hi all,
What is the problem with this code? -
-
long char a,b,c,d,e;
-
...
-
cin>>a;
-
You declare variable "a" as long char, then you instruct your code to read from the standard input stream and store the result in a.
No wonder why you can only read one character at a time.
|  | Moderator | | Join Date: Nov 2006 Location: USA
Posts: 3,929
| | | re: C++ Read in 'student record' information, print it out again.
I would recommend looking into using strings. If, for some odd reason you can't, you can always use a char*.
I have also combined your threads that are on the same problem - in the future, please keep all questions about the same code in a single thread. As this is the second time in 5 hours that I have had to warn you (and you're a Guru?!), you are now responsible for reading and following the Posting Guidelines of this site. If you fail to follow these, we will have to take further action against your account.
|  | Banned | | Join Date: Aug 2007 Location: Lahore Pakistan
Posts: 929
| | | re: C++ Read in 'student record' information, print it out again. Quote:
Originally Posted by sicarie I would recommend looking into using strings. If, for some odd reason you can't, you can always use a char*.
I have also combined your threads that are on the same problem - in the future, please keep all questions about the same code in a single thread. As this is the second time in 5 hours that I have had to warn you (and you're a Guru?!), you are now responsible for reading and following the Posting Guidelines of this site. If you fail to follow these, we will have to take further action against your account. Hello,
You are right but only for this post.
The both of later posts are different but the title is same.
Anyway
I have used char* but after running the programe when it terminates C++ gives an error and closed itself.
When i iwrite this Ali Rizwan with a space between Ali and Rizwan it do as i say means it donot ask for next three or four input it switches to the fourth one and so on
bu if i donot put any space it do right.
How can i declare a character type variable so that user can store any type of word in it.
Thanx
|  | Moderator | | Join Date: Nov 2006 Location: USA
Posts: 3,929
| | | re: C++ Read in 'student record' information, print it out again. Quote:
Originally Posted by Ali Rizwan Hello,
You are right but only for this post.
The both of later posts are different but the title is same. Your question was merely an extension of the other question - it was concerning the same assignment - and therefore helps to have the history when responding. Quote:
Originally Posted by Ali Rizwan I have used char* but after running the programe when it terminates C++ gives an error and closed itself. Then can you re-post your code? I also suggested using string. Did you try that? Quote:
Originally Posted by Ali Rizwan When i iwrite this Ali Rizwan with a space between Ali and Rizwan it do as i say means it donot ask for next three or four input it switches to the fourth one and so on
bu if i donot put any space it do right. Right, this is an issue with cin. You need to use another method to capture a selection with a space in it. Cin stops at whitespace. Quote:
Originally Posted by Ali Rizwan How can i declare a character type variable so that user can store any type of word in it.
Thanx You can't do it in a char (unless you are storing 'a' or 'I'), because of the size of a char. You need a char[] or a string to hold multiple char variables.
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,449 network members.
|