GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #11  
Old 04-Mar-2004, 08:53
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
Hi Dewil. I am going to give you an outline of how I would write this program, but you will need to put it together. It appears that you are fairly new to C, but you should know enough to get this going. If not, start looking through your reference book.
  • Ask the user to input a string - You've already got this.
  • Store the string - I would suggest using fgets for this.
  • Parse the string character by character.
  • If the character is valid, print it using printf("%c",*character)
  • When the string is finished, print a newline printf("\n");
  • Make this loop until the user types in a string that is a keyword, ie exit

I would make a seperate function that would take a char and compare it to your valid list. I would call it, is_valid and have it return a 1 if it is valid and a 0 if it is not. That way I could use it in my main loop like:

CPP / C++ / C Code:
if(is_valid(*character) )
    printf("%c",*character);

Parsing a string in C is very easy, because of the null termination, I would use a char* to parse it until it becomes NULL.

CPP / C++ / C Code:
char* character;
char string[100];

...
character = input_string;
while(*character){
   ...
  character++;
}

This should get you started.
 
 

Recent GIDBlogOnce again, no time for hobbies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
some Great site for programming issues priyanka Web Design Forum 8 19-Dec-2005 09:55
C programming help!!! sanman10535 C Programming Language 4 27-Feb-2004 17:53
question of practice magiccreative C++ Forum 1 06-Feb-2004 08:17
Web and Flash design. PHP, MySQL, ASP, JSP programming. artem Web Design Forum 4 28-Apr-2002 05:36

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 02:31.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.