any suggestions on how to repalce the specific character with a different character within the string while running a loop? I am in a no prereq class and am not really connecting with this programming, any help, suggestions, tips on the specifically the replacment issue?

Recommended Answers

All 2 Replies

loop, test character chode, if one that needs replacing replace it, win.

any suggestions on how to replace the specific character with a different character within the string while running a loop? I am in a no prereq class and am not really connecting with this...

Hint was:

loop, test character code, if one that needs replacing replace it...

Further hint:
you could use some C code something like this:

char test[] = "The cat was fat."; /* recall '\0' terminated */
char* p = test; /* get a pointer to first char */

/* change each small 't' to 'b' ... */
/* loop until reach terminal '\0' char */
while( *p ) 
{ 
    if( *p == 't' ) *p = 'b' ; 
    ++p; 
}

printf( test ); /* The cab was fab. */
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.