T
Thomas Wintschel
David Sobey said:Hi
Sorry bout this basic prob. Got a file called file.obj. tryna read the first
line from it as a string and print it to the screen. getting errors:
#include "stdafx.h"
#include <stdio.h>
#include <fstream.h>
#include <iostream.h>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
string Buffer;
ifstream FileStream("File.obj");
FileStream.getline(Buffer, '\n');
cout << Buffer << endl;
FileStream.close();
return 0;
}
Also, how would i print just the first character of the string (Buffer)? Any
help much appreciated.
cheers
dave
I can see any number of potential problems. When you say 'getting errors'
do you mean compile time or runtime errors? Is the file a text file or a
binary file? Why is it that you do not say what the actual errors are?
They are compile time aren't they?
Tom