473,385 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

strings ending in 'ion'

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
2 1250
horace1
1,510 Expert 1GB
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
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

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

Similar topics

1
by: Rolf Kemper | last post by:
Hi All, I'm quite sure that somebody of you have already a solution for this: ABC1 ABC12 ABC2 ABC21 ABC3
388
by: maniac | last post by:
Hey guys, I'm new here, just a simple question. I'm learning to Program in C, and I was recommended a book called, "Mastering C Pointers", just asking if any of you have read it, and if it's...
20
by: plahey | last post by:
I thought I understood raw strings, then I got bitten by this: x=r'c:\blah\' which is illegal! I thought that \ had no special meanning in a raw string so why can't it be the last character?...
8
by: Bob | last post by:
I need to create a Regex to extract all strings (including quotations) from a C# or C++ source file. After being unsuccessful myself, I found this sample on the internet: ...
3
by: baje | last post by:
hi new to c++; have an array to hold five names; however having problems reading in the names into the array.here the code i have #include<iostream> using std::cout; using namespace std;...
4
by: CoreyWhite | last post by:
/* WORKING WITH STRINGS IN C++ IS THE BEST WAY TO LEARN THE LANGUAGE AND TRANSITION FROM C. C++ HAS MANY NEW FEATURES THAT WORK TOGETHER AND WHEN YOU SEE THEM DOING THE IMPOSSIBLE AND MAKING...
5
by: David Mathog | last post by:
I'm looking at a program which stores perl scripts in an array. Each script is stored as a single entry in that array, and the whole set of them live in a single header file (escaped out the wazoo...
14
by: Karch | last post by:
I need to find the fastest way in terms of storage and searching to determine if a given string contains one of a member of a list of strings. So, think of it in terms of this: I have a string such...
7
by: JohnF | last post by:
I have a function textag($expression){...} whose $expression argument is a string that can contain substrings like \alpha with one backslash or like a&b\\c&d with two backslashes. If I write...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.