Plz chck this 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:confused:. 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<
-
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:confused:. 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<
i dont see any problem in your code. It must be working fine and must crate the file. Check the file 1) if you are directly running the .exe, at the location of the exe file. 2) if you are executing from the vc projecy, then the file will be created at the location of workspace and project files i.e. where .dsw/.dsp exists. Rahim Rattani Software Engineer, Matrix Systems (Pvt) Ltd., Karachi - Pakistan
-
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:confused:. 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 wrote: file.open("computerspec.txt"); Does this statement create the file if it does not exist?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
-
rose aashii wrote: file.open("computerspec.txt"); Does this statement create the file if it does not exist?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
Yes it does creates the file, if the file does not exist. The actual syntax is file.open(filename, open flags, protection specifications). The default open flag is ios::out which creates the file if it does not exists. To avoid the file creation if it does not exists another flag ios::nocreate is used. Rahim Rattani Software Engineer, Matrix Systems (Pvt) Ltd., Karachi - Pakistan
-
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:confused:. 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<
I´ve done the following changes in your code, and it works just fine for me. #include #include #include using namespace std; struct computerspec { int ram; int hdisk; }compuspec; void main() { cout<<"Enter the RAM capacity"<>compuspec.ram; cout<>compuspec.hdisk; cout<