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 say开发者_如何学运维ing: 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
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.
You need to include the appropriate header file -- <fstream>
.
精彩评论