473,385 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

file handling

what's wrong in this problem/program? this code cannot be run in borlan c++..??
#include <iostream.h>
#include <cstring.h>
#include<fstream.h>
#include<string.h>
main ()

{
string name = "";
string course = "";
string id = "";
string year = "";
int x;
string surname = "";
string mid = "";
string subject = "";
string subject1 = "";
string subject2 = "";
string subject3 = "";
string subject4 = "";
string subject5 = "";
string subject6 = "";

cout << "\t\t\t***Student Details***\n\n";
int True=1;
while(True)
{cout << "\n\n\t\t\t(1) for Register\n";
cout <<"\t\t\tAlready have account? (2) for Log In: ";
cin >> x;
cout<<"(3) Enter to Display Student Information List";
cin>>x;
cout << "\n\n";

if (x==1)
{
cout << "Enter Student's ID no: ";
cin >> id;
cout << "\nMust be all Capitalized!\n";
cout << "\n\t\tName: ";
cin >> name;
cout << "\n\t\tLast Name: ";
cin >> surname;
cout << "\n\t\tMiddle Initial: ";
cin >> mid;
cout << "\n\t\tCourse: ";
cin >> course;
cout << "\n\t\tYear: ";
cin >> year;
cout << "\n\nSubject Taken: (ONLY MAJORS SUBJECT)\n";
cout << "Example: Section Code and Description\n";
cout << "Example: CSC1 CISCO1\n";
{
cin >> subject;
cin >> subject1;
cin >> subject2;
cin >> subject3;
cin >> subject4;
cin >> subject5;
cin >> subject6;
}

//cout << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";

//cout << "\n\nStudent Details: ";
//cout << "\n\tID No: " << id;
//cout << "\n\tName: " << name;
//cout << "\n\tCourse: " << course;
//cout << "\n\tYear: " << year;

//cout << "\n\nSubject Taken: \n";
//cout << subject << " " << subject1 << "\n" << subject2 << " " << subject3 << "\n" << subject4 << " " << subject5 << " " << subject6;

ofstream outfile;
outfile.open("student.txt", ios::app);

if (outfile.is_open())
{
cout<<"Student ID No. : ";
getline(cin, id);
cout<<"Name: ";
getline(cin, name);
cout<<"Last name: ";
getline(cin, surname);
cout<<"Course: ";
getline(cin, course);
cout<<"Year: ";
getline(cin, year);
cout << "\n\nSubject Taken: \n";
cout << subject << " " << subject1 << "\n" << subject2 << " " << subject3 << "\n" << subject4 << " " << subject5 << " " << subject6;

outfile<<id<<"|"<<name<<"|"<<surname<<"|"<<course< <"|"<<year<<"|"<<subject<<"|"<<subject1<<"|"<<subj ect2<<"|"<<subject3<<"|"<<subject4<<"|"<<subject5< <<"|"<<subject6<<"|";

outfile.close();
}
else
cout<<"File cannot be opened." ;
}

else
{
cout << "Enter I.D no.: ";
cin >> id;
cout << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";

cout << "\n\nStudent Details: ";
cout << "\n\tID No: " << id;
cout << "\n\tName: " << name;
cout << "\n\tCourse: " << course;
cout << "\n\tYear: " << year;

cout << "\n\nSubject Taken: \n";
cout << subject << " " << subject1 << "\n" << subject2 << " " << subject3 << "\n" << subject4 << " " << subject5 << " " << subject6;
True=0;
}

}

}
Oct 29 '15 #1
2 1387
donbock
2,426 Expert 2GB
Do you get compile errors, run-time errors, or is the behavior of your program different from what you expected?

By the way, enclosing your program in Code Tags is helpful.
Oct 29 '15 #2
weaknessforcats
9,208 Expert Mod 8TB
The main error is that the code is missing:

Expand|Select|Wrap|Line Numbers
  1. using namespace std;
right after your #include statements.

Unless this line is present, he string becomes std::string, cout becomes std::cout, etc.

There are two other errors which I'm sure you will find and correct.
Oct 29 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Hans-Joachim Widmaier | last post by:
Hi all. Handling files is an extremely frequent task in programming, so most programming languages have an abstraction of the basic files offered by the underlying operating system. This is...
11
by: Josh | last post by:
Hi, I am having a problem with Python. I am new to Python as a programming language, but I do have experience in other languages. I am experiencing strange problems with File handling and wonder...
1
by: Sean W. Quinn | last post by:
Hey folks, I have a question regarding file handling, and the preservation of class structure. I have a class (and I will post snippets of code later in the post) with both primitive data...
9
by: Jay Kim | last post by:
Hi, We're implementing a Windows application using Visual Basic .NET. One of the key features we need to implement is that we should be able to get the accurate byte offset of user selected...
4
by: BHARAT | last post by:
Hi I am a little bit new to C's advanced topics: I need help in file handling. I have Turbo C and I wrote a simple program to write data to file: #include<stdio.h> #include<dir.h>...
7
by: D & J G | last post by:
Is there a way to instruct Windows file-handling - 'Opens with:' - from within VB6? I want to ensure that files with the .rtf (rich text) extension always go to Word Pad, no matter which future...
3
by: Binu C | last post by:
hi am new to VB. I need to develop an application. The requirements are as follows: We have a notepad which consists of some data(Say A). Now we have a form in which we have some text fields & a...
9
by: lokeshrajoria | last post by:
hello everybody, i need some help in binary file handling in perl. can anybody give me some information about binary file. actully i am reading data from some text file and extracting some usefull...
3
by: neha_chhatre | last post by:
hey please help me execute the code on ubuntu in C #include<stdio.h> #include<stdlib.h> int main() { FILE *fp; char ch; float ticktock;
2
by: phpmagesh | last post by:
Hi, I want to create a xml document using php-file handling . that i have a Database named as Total_category and table name as students_one. and i have fields like name, age, email, title,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.