I want to read a whole text file a once into a single string. I have used the fread() function in the following way:
My input.txt is:Code:#include <stdio.h> int main() { FILE *fInp; char buffer[1000]; fInp = fopen("input.txt", "r"); fread(buffer, 2, 1000, fInp); printf("%s", buffer); getchar(); }
However it produces a string:Code:i want to read that into a single string
How to get rid of that crap if i do not know beforehand how many characters are my input.txt?Code:i want to read that into a single stringĚĚĚĚĚĚĚĚĚ<loads of identical crap>ĚĚĚĚĚĚĚĚĚĚĚĚhűbĚĚĚĚĚĚĚĚHűbĚĚĚĚ«_·=\ű



LinkBack URL
About LinkBacks



