Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

read string from binary file in c++

fstream readStringBF;
	readStringBF.open("Name.dat", ios::in | ios::binary);
	char n[30];
	if (readStringBF.is_open()) {
		readStringBF.read(n, 30);
		n[readStringBF.gcount()] = NULL;		//append string terminator
		cout << n;
		readStringBF.close();
	}
	else cout << "Unable to open file!";
 
PREVIOUS NEXT
Tagged: #read #string #binary #file
ADD COMMENT
Topic
Name
9+6 =