word count in C
Hi guys
So for part of an assignment i've got to get the word count of a file. I've done characters and lines.. Words are a bit different though
it's not like you can count the number of spaces and add one, because that just counts spaces (i.e if there is more then one space in-between words then it will count that as two words when actually it should only be counting one word).
So i thought to my self a two dimensional array (string?).
Using microsofts secure version of things (_s, if you don't know what this is then just say without the secure version and ill try and work it out), i've tried multiple ways, but my lecturers just have not covered this material (nor half the other stuff i've done for this assignment.. )
was wondering if you guys could help
//Places file 1 into an arrayrewind(file_in); //THIS IS ALL A TEST, CHECK FOR PRINTFwhile ((f=fgetc(file_in)) !=EOF){if (isupper(f) || islower(f)){arrayfile1[q][p] = f;p++;}else{arrayfile1[q][p] = '\0';q++;}}
Was looking at something similar on Reddit the other day, might be of use to you.
http://www.reddit.com/r/dailyprogrammer/comments/2nynip/2014121_challenge_191_easy_word_counting/
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now