first commit
This commit is contained in:
29
vulp.c
Normal file
29
vulp.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char* fn = "/tmp/XYZ";
|
||||
char buffer[60];
|
||||
FILE* fp;
|
||||
|
||||
/* get user input */
|
||||
scanf("%50s", buffer);
|
||||
|
||||
if (!access(fn, W_OK)) {
|
||||
fp = fopen(fn, "a+");
|
||||
if (!fp) {
|
||||
perror("Open failed");
|
||||
exit(1);
|
||||
}
|
||||
fwrite("\n", sizeof(char), 1, fp);
|
||||
fwrite(buffer, sizeof(char), strlen(buffer), fp);
|
||||
fclose(fp);
|
||||
} else {
|
||||
printf("No permission \n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user