Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- void copiaConteudo(FILE *arquivo, FILE *arquivo1){
- int nLinhas;
- char ler[100];
- char lu[20];
- char ch = fgetc(arquivo);
- while(!feof){
- if(ch=='.') {
- nLinhas++;
- }
- if(nLinhas%2!=0 && fgets(ler,100,arquivo)!=NULL){
- printf("%s", ler);
- fprintf(arquivo1,"%s",ler);
- }
- }
- }
- int main() {
- FILE *arquivo = fopen("f1.txt","r");
- if (arquivo == NULL)
- {
- printf ("Não foi possível abrir o arquivo");
- return 1;
- }
- FILE *arquivo1 = fopen("f2.txt","w");
- if (arquivo1 == NULL)
- {
- printf ("Não foi possível abrir o arquivo");
- return 1;
- }
- copiaConteudo(arquivo,arquivo1);
- fclose(arquivo);
- fclose(arquivo1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement