Skip to content

Instantly share code, notes, and snippets.

@winhtut
Last active December 10, 2019 08:27
Show Gist options
  • Save winhtut/d0486a5cea54d86637de676ee53e4c55 to your computer and use it in GitHub Desktop.
Save winhtut/d0486a5cea54d86637de676ee53e4c55 to your computer and use it in GitHub Desktop.
FileProcessingWithC
#include <stdio.h>
int main() {
FILE *fptr;
int account=101;
char name[]="WinHtut";
double balance=10.1;
fptr = fopen("1hello.txt", "w");
if(fptr==NULL){
printf("Somethings wrong with this process");
}else{
fprintf(fptr, "%d %s %.2f\n", account, name, balance);
fclose(fptr);
printf("All process are complete\n");
}
return 0;
}
#include <stdio.h>
int main() {
int i;
FILE * fptr;
char str[] = "We are Myanmar Crazy Coder\n";
fptr = fopen("hello.txt", "w");
for (i = 0; str[i] != '\n'; i++) {
fputc(str[i], fptr);
}
fclose(fptr);
return 0;
}
#include <stdio.h>
int main() {
FILE * fptr;
fptr = fopen("1hello.txt", "w+");
if(fptr==NULL){
printf("Something wrongs");
}else{
fputs("Myanmar Crazy Coders(GreenHackers)\n ", fptr);
fputs("it is more clear than fputc() \n", fptr);
printf("All process are successfully");
fclose(fptr);
}
return (0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment