Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- FILE * f = fopen("prova.txt","w");
- int a = 5;
- a = fwrite(&a, sizeof(int), 1, f);
- if (a !=1 ){
- perror("write");
- exit(EXIT_FAILURE);
- }
- char *ciao="ciao!";
- a = fwrite(ciao, sizeof(char), 5 , f);
- if (a !=5 ){
- perror("write");
- exit(EXIT_FAILURE);
- }
- a = 7;
- a = fwrite(&a, sizeof(int), 1, f);
- if (a !=1 ){
- perror("write");
- exit(EXIT_FAILURE);
- }
- ciao="settete";
- a = fwrite(ciao, sizeof(char), 7 , f);
- if (a !=7 ){
- perror("write");
- exit(EXIT_FAILURE);
- }
- a = 3;
- a = fwrite(&a, sizeof(int), 1, f);
- if (a !=1 ){
- perror("write");
- exit(EXIT_FAILURE);
- }
- ciao="bam";
- a = fwrite(ciao, sizeof(char), 3 , f);
- if (a !=3 ){
- perror("write");
- exit(EXIT_FAILURE);
- }
- exit(EXIT_SUCCESS);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement