473,609 Members | 2,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

file handling

8 New Member
what's wrong in this problem/program? this code cannot be run in borlan c++..??
#include <iostream.h>
#include <cstring.h>
#include<fstrea m.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***Stude nt Details***\n\n" ;
int True=1;
while(True)
{cout << "\n\n\t\t\t (1) for Register\n";
cout <<"\t\t\tAlread y 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\tMidd le Initial: ";
cin >> mid;
cout << "\n\t\tCour se: ";
cin >> course;
cout << "\n\t\tYear : ";
cin >> year;
cout << "\n\nSubjec t 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\nStuden t Details: ";
//cout << "\n\tID No: " << id;
//cout << "\n\tName: " << name;
//cout << "\n\tCourse : " << course;
//cout << "\n\tYear: " << year;

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

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

if (outfile.is_ope n())
{
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\nSubjec t Taken: \n";
cout << subject << " " << subject1 << "\n" << subject2 << " " << subject3 << "\n" << subject4 << " " << subject5 << " " << subject6;

outfile<<id<<"| "<<name<<"|"<<s urname<<"|"<<co urse<<"|"<<year <<"|"<<subject< <"|"<<subject1< <"|"<<subject2< <"|"<<subject3< <"|"<<subject4< <"|"<<subject5< <<"|"<<subject6 <<"|";

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

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

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

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

}

}
Oct 29 '15 #1
2 1397
donbock
2,426 Recognized Expert Top Contributor
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 Recognized Expert Moderator Expert
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
3195
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 indeed also true for our language of choice, Python. Its file type allows some extraordinary convenient access like: for line in open("blah"): handle_line(line)
11
2853
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 if anyone else has seen this or knows what I am doing wrong. I am simply trying to open a file for read and iterate through until the end of file. I am able to do so without a problem, but here's the catch: The open statement is only working on...
1
3258
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 structures (ints), and more complex data structures (strings and vectors) in it, and would like to write the entire class to a data file that could then be read back and loaded. However I'm having difficulty with this -- I found out (due to an...
9
2948
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 text in the file. We've been trying to use the RichTextBox control to load
4
4604
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> #include<conio.h> #include<stdlib.h>
7
7280
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 computer uses my program. TIA Don
3
1860
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 command button. when we click cmd button once the data from the notepad should be read as strings of different sizes & displayed in the text boxes. Again when we click the cmd button the data in various text fields are written to another...
9
3241
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 information from there and want store in my own binary file with .vbf extension ( not like .dat file.) i am putting code here for reading text file and extract some information from there but how can i store that information in my own binary file. ...
3
2380
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
2488
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, specification etc.. inside that students_one table. what i want to do is, i want to create a xml file with this details as shown below: <total_category> <students_one> <name>xxxxx</name>
0
8138
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8090
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8229
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8408
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5523
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4030
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
1399
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.