acassis commented on issue #898: URL: https://github.com/apache/incubator-nuttx-apps/issues/898#issuecomment-1260148661
@ryancb4 I think you missing basic concepts of the C language, when you use out_string[1] to are referencing to value at position 1, but a pointer to the position 1. This way, only write(outfd, out_string, 22); is correct. You can try it in a Linux machine to see the issue: ``` #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> #define ARRAYSIZE 22 static char out_string[] = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56}; int main(void) { int fd; int ret; fd = open("/tmp/test.txt", O_RDWR | O_CREAT); if (fd < 0) { int error = errno; printf("Error %d opening /tmp/test.txt\n", error); return -1; } ret = write(fd, out_string, ARRAYSIZE); if (ret < ARRAYSIZE) { printf("Error writting array to the file\n"); goto close_exit; } printf("Data written to the file\n"); close_exit: close(fd); return 0; } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org