| վҳ | ҵ | С | | ˲ | Ƶ | | | ߱ | ̳
ӭǣһͬд輼
û   
 
ܡ룺  
1685 ˹ע
ΪʲôҪʹrewind()?
ֻ¥ ղ
kevin_c
Rank: 1
ȡ·
ӣ28
רҷ֣5
ע᣺2015-10-15
ʣ91.67%
ղ
ѽ  20 ظ2 
ΪʲôҪʹrewind()?
#include<stdio.h>
#include<stdlib.h>
#define MAX 40
int main(){
    FILE *fp;
    char words[MAX];
   
    if((fp = fopen("words","a+")) == NULL){
        fprintf(stdout,"Can't open \"words\" file.\n");
        exit(0);
    }
   
    puts("Enter words to add to the fiie: press the Enter.");
    puts("key at the beginning of a line to terminate.");
    while(gets(words) != NULL && words[0] != '\0'){
        fprintf(fp,"%s",words);
    }
    puts("File contents:");
    rewind(fp);
    while(fscanf(fp,"%s",words) == 1){
        puts(words);
    }
    if(fclose(fp) != 0)
        fprintf(stderr,"Error closing file.\n");
    return 0;
}

δУΪʲôҪʹrewind()֪ıָָλ,лл.
2016-01-01 14:36
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
ȡ
304
ӣ25859
רҷ֣48889
ע᣺2011-6-22
ղ
÷:20 
ļݔĄļָʾλãĻݔһӣ[ˡԄӵġǰʹfprintf()Ҫ^ǰx𣬾Ҫ¶λļָʾ

棬㡣
2016-01-01 14:40
kevin_c
Rank: 1
ȡ·
ӣ28
רҷ֣5
ע᣺2015-10-15
ղ
÷:0 
ظ 2¥ TonyDeng
Ŷõģлл
2016-01-01 16:18
ٻظΪʲôҪʹrewind()?
ݼ...
 



| | й | Cookies | TOP | ֻ

й ȨУȨ
Powered by Discuz, Processed in 0.029498 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved