By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,159 Members | 945 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,159 IT Pros & Developers. It's quick & easy.

strings ending in 'ion'

P: 4
Hi,

I am trying to write a progam that reads a series of strings and prints only those strings eding in 'ion'. The below doesn;t seem to be working.......can anyone advise? Ta

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4.  
  5. void main() {
  6. char line[100]; 
  7. int str = 'ion'; 
  8.  
  9. printf("\n Enter a series of  strings:\n");
  10. gets(line);
  11.  
  12. while (strlen(line) >= 1){ 
  13.  
  14.  
  15. if(strrchr(line,str) != NULL)
  16.  
  17. printf("The string is : %s\n",text);
Feb 25 '07 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 1,510
for a start try changing
Expand|Select|Wrap|Line Numbers
  1. int str = 'ion'; 
  2.  
to
Expand|Select|Wrap|Line Numbers
  1. char * str = "ion"; 
  2.  
Feb 25 '07 #2

P: 4
Thanks, is there anything else wrong with it? My compiler doesn't seem to be working at the mo so I can't check...]
Feb 25 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.