Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhavpatilX authored Jun 22, 2024
1 parent aa08a13 commit f0029d7
Show file tree
Hide file tree
Showing 27 changed files with 669 additions and 0 deletions.
Binary file added file handling/CP.exe
Binary file not shown.
Empty file added file handling/Demo.txt
Empty file.
1 change: 1 addition & 0 deletions file handling/Infosystems.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C programming is native programming languageLogic Building
1 change: 1 addition & 0 deletions file handling/Marvellous.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C programming is native programming languageLogic Building
1 change: 1 addition & 0 deletions file handling/New.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C programming is native programming languageLogic Building
1 change: 1 addition & 0 deletions file handling/New2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C programming is native programming languageLogic Building
24 changes: 24 additions & 0 deletions file handling/Program381.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>

int main()
{
char Fname[20];
int fd = 0;

printf("Enter the file name you want to create : ");
scanf("%s",Fname);

fd = creat(Fname,0777);

if(fd == -1)
{
printf("Unable to create file\n");
}
else
{
printf("File is successfully created with FD %d\n",fd);
}
return 0;
}
32 changes: 32 additions & 0 deletions file handling/Program382.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>

int CreateFile(char Name[])
{
int fd = 0;
fd = creat(Name,0777);
return fd;
}

int main()
{
char Fname[20];
int fd = 0;

printf("Enter the file name you want to create : \n");
scanf("%s",Fname);

fd = CreateFile(Fname);

if(fd == -1)
{
printf("Unable to create file\n");
}
else
{
printf("File is succcessfuly created with FD %d\n",fd);
}

return 0;
}
28 changes: 28 additions & 0 deletions file handling/Program383.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>

// O_RDONLY Open for reading
// O_WRONLY Open for writing
// O_RDWR Open for reading and writing
int main()
{
char Fname[20];
int fd = 0;

printf("Enter the file name you want to open : \n");
scanf("%s",Fname);

fd = open(Fname,O_RDWR);

if(fd == -1)
{
printf("Unable to open file\n");
}
else
{
printf("File is succcessfuly opened with FD %d\n",fd);
}

return 0;
}
32 changes: 32 additions & 0 deletions file handling/Program384.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>

int OpenFile(char Name[])
{
int fd = 0;
fd = open(Name,O_RDWR);
return fd;
}

int main()
{
char Fname[20];
int fd = 0;

printf("Enter the file name you want to open : \n");
scanf("%s",Fname);

fd = OpenFile(Fname);

if(fd == -1)
{
printf("Unable to open file\n");
}
else
{
printf("File is succcessfuly opened with FD %d\n",fd);
}

return 0;
}
27 changes: 27 additions & 0 deletions file handling/Program385.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include<unistd.h>

int main()
{
char Fname[20];
int fd = 0;
char Data[] = "Marvellous";
printf("Enter the file name you want to open : \n");
scanf("%s",Fname);

fd = open(Fname,O_RDWR);

if(fd == -1)
{
printf("Unable to open file\n");
}
else
{
printf("File is succcessfuly opened with FD %d\n",fd);
write(fd,Data,10);
}

return 0;
}
32 changes: 32 additions & 0 deletions file handling/Program386.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include<unistd.h>
#include<string.h>

int main()
{
char Fname[20];
int fd = 0 , Length = 0;
char Data[100];

printf("Enter the file name you want to open : \n");
scanf("%s",Fname);

fd = open(Fname,O_RDWR);

if(fd == -1)
{
return -1;
}

printf("Enter the data that you want to write in file : \n");
scanf(" %[^'\n']s",Data);

Length = strlen(Data);

//write(kashyat,kay,kiti);
write(fd,Data,Length);

return 0;
}
32 changes: 32 additions & 0 deletions file handling/Program387.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include<unistd.h>
#include<string.h>

int main()
{
char Fname[20];
int fd = 0 , Length = 0;
char Data[100];

printf("Enter the file name you want to open : \n");
scanf("%s",Fname);

fd = open(Fname,O_RDWR | O_APPEND);

if(fd == -1)
{
return -1;
}

printf("Enter the data that you want to write in file : \n");
scanf(" %[^'\n']s",Data);

Length = strlen(Data);

//write(kashyat,kay,kiti);
write(fd,Data,Length);

return 0;
}
29 changes: 29 additions & 0 deletions file handling/Program388.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include<unistd.h>
#include<string.h>

int main()
{
char Fname[20];
int fd = 0 , Length = 0;
char Data[100];

printf("Enter the file name you want to open : \n");
scanf("%s",Fname);

fd = open(Fname,O_RDWR);

if(fd == -1)
{
return -1;
}

//read(kuthun,kashat,kiti);
read(fd,Data,13);

printf("Data from file is %s",Data);

return 0;
}
30 changes: 30 additions & 0 deletions file handling/Program389.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include<unistd.h>
#include<string.h>

int main()
{
char Fname[20];
int fd = 0 , Length = 0;
char Data[100];

printf("Enter the file name you want to open : \n");
scanf("%s",Fname);

fd = open(Fname,O_RDWR);

if(fd == -1)
{
return -1;
}

//read(kuthun,kashat,kiti);
Length = read(fd,Data,13);

printf("Data from file is \n");
write(1,Data,Length);

return 0;
}
32 changes: 32 additions & 0 deletions file handling/Program390.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include<unistd.h>
#include<string.h>

int main()
{
char Fname[20];
int fd = 0 , Length = 0;
char Data[100];

printf("Enter the file name you want to open : \n");
scanf("%s",Fname);

fd = open(Fname,O_RDWR);

if(fd == -1)
{
return -1;
}

//read(kuthun,kashat,kiti);
Length = read(fd,Data,13);

printf("Data from file is \n");
write(1,Data,Length);

close(fd);

return 0;
}
32 changes: 32 additions & 0 deletions file handling/Program391.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include<unistd.h>
#include<string.h>

int main()
{
char Fname[20];
int fd = 0 , Length = 0;
char Data[100];

printf("Enter the file name you want to open : \n");
scanf("%s",Fname);

fd = open(Fname,O_RDONLY);

if(fd == -1)
{
printf("Unable to open file \n");
return -1;
}

while((Length = read(fd,Data,sizeof(Data))) != 0)
{
write(1,Data,Length);
}

close(fd);

return 0;
}
35 changes: 35 additions & 0 deletions file handling/Program392.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include<unistd.h>
#include<string.h>

int main()
{
char Fname[20];
int fd = 0 , Length = 0;
char Data[100];
int Size = 0;

printf("Enter the file name you want to open : \n");
scanf("%s",Fname);

fd = open(Fname,O_RDONLY);

if(fd == -1)
{
printf("Unable to open file \n");
return -1;
}

while((Length = read(fd,Data,sizeof(Data))) != 0)
{
Size = Size + Length;
}

printf("Size of File is %d bytes\n",Size);

close(fd);

return 0;
}
Loading

0 comments on commit f0029d7

Please sign in to comment.