#define USERNAME_SIZE 10 int main() { int fd; fd = fd("user.dat", O_CREAT | O_RWDR, 0666); if (fd == -1) { write(1,"There is an error opening the file",35); } write(1,"Enter the username",18); char username[USERNAME_SIZE]; char c; int count = 0; do { read(0, &c, 1); if (c == '\n') break; username[count++] = c; } while (count < USERNAME_SIZE - 1); username[count] = 0; write(fd,username,count); close(fd); return 0; }
read
fd = fd("user.dat", O_CREAT | O_RWDR, 0666);
fd = open("user.dat", O_CREAT | O_RWDR, 0666);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)