Originally Posted by
Fillis52
hello,
I have a proc file which contains a buffer of ints, which I want to be able to read from user space.
I assume you open the file as you would a normal file
Code:
File fp* = fopen("/proc/kernelRead","r");
but from here I am unsure how you would read. would you use fscanf? if you do, how would the proc.read method get called?
thanks for any help!
You want something like this?
Code:
#include <stdio.h>
int main(){
FILE *fp = fopen("/proc/cpuinfo","r");
char c;
while (c != EOF){
c = fgetc(fp);
printf("%c", c);
}
return 0;
}
I just read/printed to console character by character. There are a lot of ways to mess around with this. You can also seek files and do a lot of clever stuff. What is the output of the file like? Will it be similar each time? Could you parse it or tokenize it? Etc~