Hardware Reference
In-Depth Information
Returns the output bytes read from the file as an array.
Example
int getHours() {
char output[5];
system("curl http://nextmakemagazine.appspot.com/simple > response.txt");
FILE *fp;
fp = fopen("response.txt", "r");
fgets(output, 5, fp);
fclose(fp);
return atoi(output);
}
fopen
This function from the C library is available within Galileo to open a file from
the Linux file system. See “Another Approach to Passing Data” on page 117
for more information.
Syntax
fopen(filename, mode);
Parameters
filename
The name of the file to open
mode
“r” to read an existing file, “w” to write a new file or overwrite existing
file, “a” to append to a file or create it if it doesn't exist.
Return value
A pointer to a file.
Example
int getHours() {
char output[5];
system("curl http://nextmakemagazine.appspot.com/simple > response.txt");
FILE *fp;
fp = fopen("response.txt", "r");
fgets(output, 5, fp);
fclose(fp);
return atoi(output);
}
if
Executes a block of code if a particular condition is true. See “if State-
ments” on page 48 .
Search WWH ::




Custom Search