[Show all top banners]

comingsoon

More by comingsoon
What people are reading
Subscribers
:: Subscribe
Back to: Kurakani General Discussion Refresh page to view new replies
 How to count line in c?
[VIEWED 1855 TIMES]
SAVE! for ease of future access.
Posted on 10-25-13 4:48 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?        
 

I try this way and good fail many time. Any help, will be celebrate with grate appreciation. Thanks. I also try fgets() same way but didn't work as well.
int line_count ()
{
    FILE * fp;         // file open from here.
    int i=0;
    int c;
    if ((fp = fopen ("file.txt", "a")) != NULL){
        while ((c=fgetc(fp))!=EOF)
        {
            if (c=='\n') {
                i++;
            }
           
        }
        fclose(fp);
    }
    else printf(" Error.\n");
    return i;
}


Last edited: 25-Oct-13 04:52 PM
Last edited: 25-Oct-13 04:54 PM

 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 7 days
Recommended Popular Threads Controvertial Threads
नेपालमा क्रिस्चियनहरुले किन नेपाली हिन्दुहरुलाइ धर्म परिवर्तन गराउदैं छन् ?
What stocks to buy -- Any recommendation
❤️ चिक्नी चमेली ❤️
ट्रंप २०२०
Ron Paul Revolution 2008
🚨🚨🚨 नाज'स् वर्ल्ड 🚨🚨🚨
उस्तै उस्तै हामी
Nas and The Bokas: Coming to a Night Club near you
डर लाग्न थालेको छ |
आयाहूआस्का
महिलाहरु गाँजाको सेवन गर्दै गरेको दृश्यहरु
Fox News: Wear the Damn Mask, it is not political issue but a public health issue.
Visit Reeyas Kitchen for Nepali Food Recipes
स्कूलमा पढेका कथा - भुतको शिकार, शिशिर बसन्तको कथा देखि टाउकोको मोल सम्म
साझा बोका हस्ती २०१७
Job! Job!! Job!!!
जोडि त भाग्यले जुराउँछ - हिरोइन स्वेताले यसरि दोश्रो पटक बिहे गर्न लागिन
लगातार २ छोरि हुदाको पिडा
ए १ पनि पुगेनछ ?
200 billion profit in vaccines for Bill Gates
Nas and The Bokas: Coming to a Night Club near you
नेपालमा क्रिस्चियनहरुले किन नेपाली हिन्दुहरुलाइ धर्म परिवर्तन गराउदैं छन् ?
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters