// ReadingFromFiles.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <cctype> #include <cstring> #include <stdio.h> #include <cmath> #include <fstream> //for reading files #include <cstdlib> //using function for shut down using namespace std; int _tmain(int argc, _TCHAR* argv[]) { struct msq_type { char * q; char * a; char * b; char * c; char * d; char result; } qusetion; //struct msq_type qusetion; printf("begining \n"); FILE* testRead = fopen ("test.txt", "rb"); //rb = read printf("opening file \n"); if(testRead==NULL) { printf("Error: can't open file.\n"); system("pause"); return 1; } fread(&qusetion , sizeof qusetion , 1 , testRead); printf("reading \n"); printf("%s \n", qusetion.q); printf("%s \n" , qusetion.a); printf("%s \n", qusetion.b); printf("%s \n", qusetion.c); printf("%s \n", qusetion.d); printf("%c \n", qusetion.result); fclose(testRead); printf("closeing file"); return 0; } |