Okay I have some of the program completed. Ive run into some trouble. I think I have some of the psuedocode in my head, but dont really know if it is the correct way to go about doing it and really just want some advice. What I have put in the function parseString is incorrect, and I dont even know if I need to get into those functions (isalpha etc.) but thats the only way I can think of. Any input would be apprectiated. I think what needs to be done by the program is explained well in the comments.
thanks.
EDIT: sorry, forgot to mention, so far in the parseString function I have only been trying to get the count of characters.
Also, the purpose of the program is to take an input string from the user. The users string ends when they enter a '^'. Then the program should count the number of characters, words, and lines in the string.
So far I have created the function that will take the users input and put it in a string. I have the main function completed as well. I just need help with the function that will add up the characters, lines, and words.
Problems I have noted so far:
1. when the while loop is put in the parseString function the program will run but it will not do anything after the users input.
2. The if statements are non-functional. The isalnum and isspace functions are supposed to return a true value if it is an alnum or space and 0 if not. When I run the program I get an error saying that the left operand must be a 1-value.
EDIT:Changed code a little.
EDIT: I think I thought of a much better way to do this. Use pointers to iterate through the string.
to count characters- count up elements until '^'.
for words- use two pointers, one will denote the end of a word and one will denote the beginning of a new word. And just add up the number of words.
for lines- count up to every '\n' just add those up. Is that possible?
Is this a good way to do it? Im gonna try and work on it but I think ill need a little help, not very good with pointers yet.
thanks.
EDIT: sorry, forgot to mention, so far in the parseString function I have only been trying to get the count of characters.
Also, the purpose of the program is to take an input string from the user. The users string ends when they enter a '^'. Then the program should count the number of characters, words, and lines in the string.
So far I have created the function that will take the users input and put it in a string. I have the main function completed as well. I just need help with the function that will add up the characters, lines, and words.
Problems I have noted so far:
1. when the while loop is put in the parseString function the program will run but it will not do anything after the users input.
2. The if statements are non-functional. The isalnum and isspace functions are supposed to return a true value if it is an alnum or space and 0 if not. When I run the program I get an error saying that the left operand must be a 1-value.
EDIT:Changed code a little.
EDIT: I think I thought of a much better way to do this. Use pointers to iterate through the string.
to count characters- count up elements until '^'.
for words- use two pointers, one will denote the end of a word and one will denote the beginning of a new word. And just add up the number of words.
for lines- count up to every '\n' just add those up. Is that possible?
Is this a good way to do it? Im gonna try and work on it but I think ill need a little help, not very good with pointers yet.