In this code used to read the contents of a text file I get a illegal operation at the very end right. Here the code

#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

FILE *fp;

class myclass{
public:
void openfile(char *path);
};

int main()
{
char retval;

myclass s;

cout <<"Enter a path to open \n";

cin.getline(&retval, 30, '\n');

s.openfile(&retval);

system("pause");

return 0;
}

void myclass:penfile(char *path)
{
char ch;

if((fp = fopen(path, "r")) ==NULL)
cout << "Cannot open file ERROR";

ch = getc(fp);

while (ch!=EOF){
putchar(ch);
ch = getc(fp);
}
fclose(fp);
}

*How do I embed code in a post? Thanks for your help.