-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d01f022
commit afe3008
Showing
8 changed files
with
440 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"projectName": "Vitamin-C-Programming-book", | ||
"projectOwner": "KaziRifatMorshed" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,29 @@ | ||
# File Operations | ||
|
||
# Notes on File Operation with C | ||
|
||
| Function |Description | | ||
|-|-| | ||
| `fopen()` |opens new or existing file | | ||
| `fprintf()`| write data into the file \["ফাইল" স্ট্রিম, কি স্ট্রিং ফরম্যাটে সেইভ করব, স্ট্রিম সোর্স] | | ||
| `fscanf()`| reads data from the file ` while(fscanf(fp,"%d",&temp_num)!=EOF){` | | ||
| `fputc()` |writes a character into the file | | ||
| `fgetc()` |reads a character (in loop, character by character) from file `while ((c = fgetc(fp)) != EOF) {printf("%c", c);` | | ||
| `fputs()` |put(WRITE) a whole string to the file | | ||
| `fgets()` |using while(fgets!=NULL), reads "line by line" from file with whitespace and sets to buffer string ` while (fgets(str, 300, f) != NULL) {printf("%s", str);`; `while (fgets(line, sizeof(str_line), f)) {` | | ||
| `fclose()`| closes the file | | ||
| `fseek()` |sets the file pointer to given position | | ||
| `fputw()` |writes an integer to file | | ||
| `fgetw()` |reads an integer from file | | ||
| `ftell()` |returns current position | | ||
| `rewind()`| sets the file pointer to the beginning of the file | | ||
|
||
## notes and tricks | ||
|
||
* `scanf("%[^EOF]",str);` read full file at once | ||
* `freopen("fileout.txt", "w", stdout);` directly save into the file (steam bypass) | ||
* `fprintf()` e W+ dile full file override hoy, r+ thakle shudhu oi position er char gulo | ||
* `fscanf()`: format `%c` ar `%s` er upor depend kore kivabe source theke ek ek kore collect korbe. jodi `%s` use kori then: ek ekta word by word catch kore, so, \_buff (steam) e ekta ekta kore word dhukse, without counting whitespace characters, so, while loop er vitore amake `printf()` er vitore ekta space ditei hosse Jemon silo temon paite hole `fscanf` er vitore `C` ar `printf` er vitore `S`. | ||
* `int temp = 0; while (fscanf(f_input, "%d", &temp) != EOF) {` | ||
* `while (fscanf(ptr, "%c", &str[i]) != EOF && i < 199) { i++;}` | ||
* ` while((ptr=strstr(str,word))!=NULL) {memmove(ptr,ptr+len,strlen(ptr+len)+1);}` |
Oops, something went wrong.