[英]How do I read from file using pebble c?
我試過使用可以在“常規” c中運行的函數:
const char* getfield(char* line, int num)
{
const char* tok;
for (tok = strtok(line, ";");
tok && *tok;
tok = strtok(NULL, ";\n"))
{
if (!--num)
return tok;
}
return NULL;
}
int main()
{
FILE* stream = fopen("v1.csv", "r");
char line[1024];
while (fgets(line, 1024, stdin))
{
char* tmp = strdup(line);
printf("Field 3 would be %s\n", getfield(tmp, 3));
// NOTE strtok clobbers tmp
free(tmp);
}
}
我正在嘗試讀取位於我的卵石應用程序資源文件夾中的文件名“ v1.csv”。
您不能讀寫文件,使用文件描述符或Pebble SDK中的任何f*
函數。
如果要將數據存儲在手表上,則應查看Persistent Storage API 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.