Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include <zephyr.h>
  2. #include <fs.h>
  3. #include <stdio.h>
  4.  
  5. void main()
  6. {
  7.   fs_file_t filep;
  8.   char read_buff[80];
  9.   char test_str[] = "hello_world";
  10.   ssize_t brw;
  11.  
  12.   //open file
  13.   int a = fs_open(&filep, "hello.txt");
  14.   if (a < 0){
  15.     printf("Error opening file\n");
  16.   }
  17.   printf("Done opening file\n");
  18.  
  19.   //seek
  20.   int res = fs_seek(&filep, 0, FS_SEEK_SET);
  21.   if (res) {
  22.         printf("Error seeking file %d\n",res);
  23.   }
  24.  
  25.   //write
  26.   brw = fs_write(&filep, (char *)test_str, strlen(test_str));
  27.   if (brw<0){
  28.     printf("Error writing file %d\n",brw);
  29.   }
  30.  
  31.   fs_close(&filep);
  32.   printf("Done!");
  33. }
  34.  
  35.  
  36. Output:
  37. Done opening file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement