Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- /*
- Function
- -> Build in function
- -> User define function
- */
- int main() {
- FILE *file;
- file = fopen("output.txt", "r");
- char arr[50];
- if(file == NULL) {
- printf("File does not exist\n");
- } else {
- while(fscanf(file, "%s", arr) != EOF) {
- printf("%s ", arr);
- }
- printf("\n");
- }
- }
- // int main() {
- // FILE *file;
- // file = fopen("output.txt", "w");
- // char arr[50];
- // gets(arr); // Console
- // if(file == NULL) {
- // printf("File does not exist\n");
- // } else {
- // // printf("%s\n", arr); // Console
- // // fputs(arr, file); // File
- // fprintf(file, "%s", arr);
- // fclose(file); // Closing the file
- // }
- // }
- /*
- Creating a new File
- fopen("file path", file_mode);
- opening an existing file
- fopen("file path", file_mode);
- closing a file
- fclose(file_pointer);
- Reading from and writing information to a file
- To write something in a file ->
- fputs(string, file)
- fprintf(file_pointer, formate_specifier, variable_Name)
- To read something in a file ->
- EOF = End of File
- fgets(variable, size, file_pointer)
- fscanf(file_pointer, formate_specifier, variable_name) ---> %[^\n]
- */
- /* Projects
- -----------
- ---> Structure
- --> insertion
- --> delete (optinal)
- --> update
- --> query/search
- ---> File (optional) -> mark thakbe
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement