c++ string

Hi!

I have to write a programme where i should read string from a .TXT file. I have a problem with it. There are words in this file which are separated with space (for instance:DAD MUM CHILD etc). I would like to read the worlds like all words are read at a different place(so i would like to read the text from space to space). I tried to do it in several ways, but i also failed.

I would be greatful if anyone could help me. I will have a final exam at the end of the year and it is important to me.

Moreover, I use these libraries:
#include <string.h>
#include <stdio.h>
#inlcude <stdlib.h>
THX
Now you use one more:
#include <string>
and you read a word with:
1
2
string word;
cin >> word;
It is not running. It says that string is undeclared.
It's in the std namespace. Either write std::string and std::cin or add using namespace std; at the beginning.
You also need to include <iostream> for std::cin.
Last edited on
wasn't it because he runs at old compiler? you can see it in his header inclusion

1
2
3
#include <string.h>
#include <stdio.h>
#inlcude <stdlib.h> 


btw, don't you include the fstream?
Topic archived. No new replies allowed.