char arrays

i want a statement that will read input from a file and store it into char arrays.
i know it is getline but i cant figure out the parameters...
thanks man but i have viewed it 100 times this from this moring...my specific problem is with taking input from file... i think that i am still not able to fully comprehend the reference.:(
Have you tried the ">>" operator instead? It's whitespace delimited without the switch but it could help you. http://www.cplusplus.com/reference/iostream/istream/operator%3E%3E/
Last edited on
Right. I was going to link to reading files tutorial but they didn't use getline there, so I posted this instead. Silly me..
example:
1
2
3
4
std::ifstream file("hello.txt");
char string[80];
file.getline(string, 80);
std::cout << string;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
	
        int length;
	char * buffer;
	
	std::ifstream is;
	is.open("file.text", std::ios::binary);
	
	// get length of file:
	is.seekg(0, std::ios::end);
	length = is.tellg();
	is.seekg (0, std::ios::beg);
	
	// allocate memory:
	buffer = new char[length];
	
	// read data as a block:
	is.read(buffer, length);
	is.close();

	
	// deallocate the memory.
	delete [] buffer;
thanks it works good @hamsterman
Topic archived. No new replies allowed.