Click here to Skip to main content
15,886,740 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi there!
i want to make a program which takes 5 word or string from user .
then search the last four word for same cases and convert them to $ mark,this program should not know A and a as different cases .

for example:
input:
software
IT
HARDware

output:
software
I$
H$$D$$$$

please help me thank you
Posted
Comments
Richard MacCutchan 30-Oct-14 7:37am    
Your question and your sample do not seem to match. You also need to be more explicit about what help you need. How much of this code have you already written and where are you stuck?
OriginalGriff 30-Oct-14 7:45am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.
[no name] 30-Oct-14 8:44am    
For searching/comparing you can make a copy of your five Inputs and convert the copies to upercase. Then you do your search and replace the postions in original Input strings.

1 solution

a string is also an array of chars. So you can iterate through all indexes and get a char. This char can you compare and do your thing.

const char *text = "Hello";
int l = strln(text);

for( int i=0;i<l;i++)>
{
  char c = text[i];

  if( (c >='A') && (c<='Z') )
  {
    //do you stuff
    text[i] = '$';
  } 
}


This is for pure C. There are also string classes as std::string which have some helpful functions.
 
Share this answer
 
Comments
Richard MacCutchan 31-Oct-14 14:33pm    
Won't work for 'HARDware' as in OP's question.
KarstenK 16-Nov-14 4:30am    
then he needs to start with 1 as start for i:

for( int i=1;i
Richard MacCutchan 16-Nov-14 4:50am    
I think it still will not work for HARDware. But the real point is that the original question makes no sense.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900