Hi,
I cant find an error in this code... Its supposed to read simple txt file.
Can you help me out please? The app never reads the content or crashes right awayCode:#include <iostream> #include <stdio.h> int end; int size; FILE *file; char *buffer; char *read; void Open() { if((file = fopen("text.txt", "r+")) == NULL) { printf("File not found\n"); } else { printf("File has been opened\n"); } } void Read() { if(fread(read, size, 1, file)) { std::cout << "Read from file: \n\t" << read << "\n"; } else { printf("Failed to read from file\n"); } } void Close() { if(fclose(file)) { printf("File can not be closed\n"); } else { printf("File closed\n"); } } int main(void) { Open(); Read(); Close(); std::cin >> end; }
[Dev-C++]



LinkBack URL
About LinkBacks



