I am creating a program that lets users input the contact details of a person and saves the data in a data file . However there seems to be a problem with my code as even though the data file is being created no data is being written into it.
Mixing cstdio functions and C++ streams is IMO a bad practice, but when you mix anything with gets() you have a recipe for disaster. You need to stop using this dangerous C function, a function that can never be used safely, and forget you have ever heard of this dangerous function. Never use any function that retrieves data to a C-string that doesn't limit the number of characters it will retrieve. Also you really should consider using std::string instead of the C-strings, they'll make your life as a programmer much much easier.
i do not know what is the problem... i use Code::Blocks with mingw compiler ..but even this program ( http://pastebin.com/bcBsBHrq ) is not working on Code::Blocks.However that code works perfectly in Turbo C++.
To run it in Code::Blocks i have made certain edits like changing the main type etc but the program does not write even a single data into the data file.
Is the syntax for data file operations for Code::Blocks different ??
There is no such thing as <iostream.h> - there is, however, <iostream>
There is no such thing as <fstream.h> - there is, however, <fstream>
There is no such thing as <string.h> - there is, however, <string>
There is no such thing as <iomanip.h> - there is, however, <iomanip>
There is no such thing as <conio.h> - don't use it
Turbo C++ is decades behind today's standards. Do not use it.