I want to create a kind of agenda of championships and when a user logs in into my "database" he has to have access for visualising the championships details. These kind of details i keep in a file. How should my function look like ? I think I should try to use something like define myFile="Desktop/Program/Visualize.txt" and somehow in a function i should have something like execlp("cat", "cat", myFile, 0); Is there necessary using pipes or sockets? Thank you so much and please forgive my mistakes.
Asked
Active
Viewed 32 times
-2
-
Please fix your formatting – tohava Nov 30 '14 at 20:30
-
I want a user to see the content of that file when he logs in.. – Roxana Mihăilă Nov 30 '14 at 20:30
-
Sorry tohava, hope now it is ok. – Roxana Mihăilă Nov 30 '14 at 20:32
1 Answers
0
There is no need to go through system calls. Instead, use this function:
void display_file(const char *fn) {
FILE *f = fopen(fn, "r");
char c;
while (1) {
c = fgetc(f);
if (c == -1)
return;
putchar(c);
}
}

tohava
- 5,344
- 1
- 25
- 47