Joined
Last Seen
-5 Reputation Points
- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
0% Quality Score
- Upvotes Received
- 0
- Posts with Upvotes
- 0
- Upvoting Members
- 0
- Downvotes Received
- 3
- Posts with Downvotes
- 2
- Downvoting Members
- 2
0 Endorsements
Ranked #72.7K
Re:
[CODE]#include<stdio.h> #include<string.h> int count(char string[]); void main(){ int i; char string[1001]; printf("String: \n"); gets(string); i = words(string); printf("No. of Words %d", i); } int count(char string[]) { int i, j, k; for(i = 0; i < strlen(string); i++){ if(string[i] == ' ') k += 1; else j += 1; } … |
|
Re:
Hello I would like to count how many words are in a string ie "PETER JOHNSON LTD" so this string contains 3 I was going to use strtok but this is too slow. Any other ideas? |