0

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?

3
Contributors
2
Replies
11
Views
3 Years
Discussion Span
Last Post by David W
0

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. */

Edited by David W

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.