Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define N 20
- int main(){
- FILE *ft;
- char name1[N];
- char frase[N];
- int cont=0;
- long int pos;
- printf("Inserire nome file di testo:");
- gets(name1);
- ft=fopen(name1, "a");
- do{
- pos=ftell(ft);
- printf("\n\nInserire una frase(max. 20 caratteri):\n\n");
- gets(frase);
- if((strcmp(frase,"indietro")==1) && (cont<2){
- cont++;
- fseek(ft, strlen(frase), SEEK_CUR);
- gets(frase);
- fprintf(ft, "%s\n", frase);}
- else if((strcmp(frase,"indietro")==1) && (cont==2){
- fprintf(ft, "%s\n", frase);
- cont--;
- }
- else{
- fprintf(ft, "%s\n", frase);
- }
- }while( strcmp(frase,"fine")==0);
- fprintf(ft,"%s\n", frase);
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement