Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- char * FileRead(char *file)
- {
- FILE *pFile; long size; char *buffer;
- pFile = fopen(file, "r");
- if (pFile != NULL)
- {
- fseek(pFile, 0, SEEK_END);
- size = ftell(pFile);
- fseek(pFile, 0, SEEK_SET);
- if (size != 0)
- {
- //buffer = new char[size + 1];
- buffer = (char*)malloc(size + 1);
- if (fread(buffer, 1, size, pFile) != NULL)
- {
- buffer[size] = '\0';
- return buffer;
- }
- }
- fclose(pFile);
- }
- return 0;
- }
- int main(void)
- {
- char *pData = FileRead("C:/1.txt");
- if (pData != 0)
- {
- printf(pData);
- getchar();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement