How to write text containing newline given as command line arguments in C?
问题 I want to create a text file with mulitple lines using system calls in C and populate it with the text provided as command line arguments. This is what I wrote: #include <stdio.h> #include <fcntl.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #define MAX_SZ 1024 int main(int argc, char *argv[]) { if (argc != 3) { printf("Invalid Number of arguments\n"); printf("USAGE: ./a.out file_name \"msg\"\n"); } else { int fd_creat, fd_open, fd_write; char file_name[MAX_SZ]; char *msg =