help me

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Dec 2007
Posts: 3
Reputation: Ljupco is an unknown quantity at this point 
Solved Threads: 0
Ljupco Ljupco is offline Offline
Newbie Poster

help me

 
0
  #1
Dec 5th, 2007
I must to write i program in C which will carry into clause(sentence) from keyboard and count how much "," have how much spaces " " have and how much times occur the word "The" for every clause(sentence). And in the end program when you carry into clause(sentence) must print all inputs particular for every clause how and the same clauses also? I must use array.

EX:
the problem is, my and, is big
In this sentence you have 6 spaces 2 full stops and word "The" is occure 1

I write some code but is not full i need someone to help me to finish the code on this program

  1. #include<stdio.h>
  2. #include<string.h>
  3. #define MAX 100
  4. int main()
  5. {
  6. char sentence[100];
  7. int spaces=0,full_stop=0;
  8. puts("Enter sentence");
  9. gets(sentence);
  10. for(i=0;sentence[i]!='\0';i++)
  11. {
  12. if (sentence[i]==',')
  13. full_stop+=1;
  14. if (sentence[i]==' ')
  15. spaces+=1;
  16. }
  17. printf(" %d %d %d %d pati\n",full_stop,spaces);
  18. return 0;
  19. }
Last edited by Ancient Dragon; Dec 5th, 2007 at 9:40 pm. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,648
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1498
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: help me

 
0
  #2
Dec 5th, 2007
Do the program one step at a time and soon you will have it done. Looks like you have the first two requirements written -- counting the commas and spaces. Next you will probably want to count the number of "the" words. After line 16 add another loop using strtok() to extract the words.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 3
Reputation: Ljupco is an unknown quantity at this point 
Solved Threads: 0
Ljupco Ljupco is offline Offline
Newbie Poster

Re: help me

 
0
  #3
Dec 5th, 2007
strtok() I dont have learn about this funktion and i dont know how to use it can you give me some code for my program to see how to finished because i realy dont have any idea ?
thanks
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,648
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1498
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: help me

 
0
  #4
Dec 5th, 2007
>>strtok() I dont have learn about this funktion and i dont know how to use it
Did you think to search google for it? There are hundreds of example to follow, such as this one.

>>i realy dont have any idea ?
Get the above working first and worry about the rest after that. Do a little at a time and you will not get so overwhelmed.
Last edited by Ancient Dragon; Dec 5th, 2007 at 11:24 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,127
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 283
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: help me

 
0
  #5
Dec 6th, 2007
Try using strstr() to search for the. Keep in mind that The and the are not the same because of the first letter.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 3
Reputation: Ljupco is an unknown quantity at this point 
Solved Threads: 0
Ljupco Ljupco is offline Offline
Newbie Poster

help me check my code and correct

 
0
  #6
Dec 6th, 2007
Here I write some code for my task but it doesent work.
Please someone to chack my code and to correcte my code
  1. #include <stdio.h>
  2. #include<string.h>
  3. int main()
  4. {
  5. char c[100][100],az='a';
  6. int n=0,t=0,t1=-1,k1=0,k2=0;
  7. int i1[1000],u1=0;
  8. int zap[1000],pra_m[1000],sog[1000],the[1000];
  9. printf("Enter how much sentence do you wont\n n=");
  10. scanf("%d",&n);
  11. printf("Enter the sentence who will be separate vith full stop.\n");
  12. int i=0,ii=0,iii=0;
  13. for(k1=0;k1<1000;k1++)
  14. {
  15. i1[k1]=-1;ako[k1]=0;zap[k1]=0;pra_m[k1]=0;sog[k1]=0;
  16. }
  17. while((t!=n)&&(t1!=n))
  18. {
  19. scanf("%c",&c[i][u1]);
  20. if(c[i][u1]=='\n')
  21. {
  22. t1++;u1++;i=0;iii=0;
  23. }
  24. i++;i1[u1]++;
  25. if(iii==0)
  26. i=0;
  27. iii++;
  28. if(ii==0)
  29. {
  30. u1=0;
  31. i=0;
  32. }
  33. }
  34. for(k1=0;k1<n;k1++)
  35. for(k2=0;k2<=i1[k1];k2++)
  36. {
  37. if(c[k2][k1]==',')
  38. {
  39. zap[k1]++;
  40. }
  41. if(c[k2][k1]==' ')
  42. {
  43. pra_m[k1]++;
  44. }
  45. if(c[k2][k1]=='t')
  46. if(c[k2][k1]=='h')
  47. if(c[k2][k1]=='e')
  48. the[k1]++;
  49. for(az='a';az<='z';az++)
  50. {
  51. if(c[k2][k1]==az)
  52. if(c[k2][k1]!='a'&&c[k2][k1]!='e'&&c[k2][k1]!='i'&&c[k2][k1]!='o'&&c[k2][k1]!='u')
  53. sog[k1]++;
  54. }
  55. }
  56. printf("\n\n");
  57. for(k1=0;k1<n;k1++)
  58. {
  59. printf("zapirki-> %d\n",zap[k1]);
  60. printf("prazni mesta-> %d\n",pra_m[k1]);
  61. printf("The-> %d\n",the[k1]);
  62. printf("soglaski -> %d\n",sog[k1]);
  63. }
  64. return 0;
  65. }
Last edited by Narue; Dec 6th, 2007 at 4:54 pm. Reason: Added code tags
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,127
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 283
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: help me check my code and correct

 
0
  #7
Dec 6th, 2007
Originally Posted by Ljupco View Post
Here I write some code for my task but it doesent work.
Please someone to chack my code and to correcte my code
No, you check your code. You tell us what it's doing wrong, and what you expected to happen instead. Also, point out where in the code you think the problem is. Then we will point out ways for you to correct the code.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C Forum


Views: 834 | Replies: 6
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC