954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Check the code!!

Hye.
i write this code to get inpur from user such as ram and hard disk capacity as integer type using structures. After that i want to create a file in which i want to save that data. In the code below it is getting input from user but not creating file. Plz tell where is my mistake.
Code is:

#include
#include
#include

void main()
{
struct computerspec
{
int ram;
int hdisk;
}compuspec;

cout<<"Enter the RAM capacity"<>compuspec.ram;


cout<>compuspec.hdisk;


cout<

Rose Aashii
Newbie Poster
9 posts since Apr 2005
Reputation Points: 10
Solved Threads: 0
 

file.open("computerspec.txt");

You need to check if the file is open so

if (file.fail())
{
cerr<<"error opening file"<<endl;
exit(1);
}
else
cout << "File opened for processing" <<endl;


the chances are you havent created that file on the hdd or even if you have it may be in the wrong directory

Acidburn
Posting Pro
511 posts since Dec 2004
Reputation Points: 12
Solved Threads: 5
 

Code tags please. http://daniweb.com/techtalkforums/announcement8-3.html .
Also it is int main not void main.

prog-bman
Junior Poster
109 posts since Nov 2004
Reputation Points: 14
Solved Threads: 4
 

Thread closed. Please don't double-post.

alc6379
Cookie... That's it
Team Colleague
2,820 posts since Dec 2003
Reputation Points: 186
Solved Threads: 147
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You