Reputation: 3207
What I am trying to do here is to find right place in a file and start writing. I gave a shot with fstream and got an error saying: variable ‘std::fstream myfile’ has initializer but incomplete type
the code I declare it is:
fstream myfile(FILENAME, ios::in|ios::out);
any comments? Or there is better way to handle this? thanks
Upvotes: 2
Views: 694
Reputation: 76601
These errors:
/tmp/ccipcc4D.o: In function `main':
grow_building.cpp:(.text+0x59): undefined reference to `std::basic_fstream<char, std::char_traits<char> >::basic_fstream(char const*, std::_Ios_Openmode)'
grow_building.cpp:(.text+0x65): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()'
grow_building.cpp:(.text+0x71): undefined reference to `std::basic_fstream<char, std::char_traits<char> >::is_open()'
mean you are not linking with the standard C++ library.
Assuming you are using gcc, you need to use g++ instead of gcc for your link statement.
Upvotes: 1
Reputation: 111278
You need to include the appropriate header file -- <fstream>
.
Upvotes: 0