I recently overheard my professor talking about being able to do something like that. I cannot find a single method that sounds like it would do that. So my question stands. In the standard getchar while loop, how would one take a peek at the next char. In this loop I pass in some arrays and have the loop switch characters from array s' chars to array news' chars for the string which is put in through command line.
anyways the code does what it is intended to do for most cases except it also has to consider "/t" etc characters as a single character not two. I was thinking of checking if(c == '\') and then checking whether the next char would be a r, t, n, etc.
TL:DR question is how do I make this loop find escape sequenced characters and consider them as one char instead of two? Thank you very much.
void tr_str(char s[], char news[]){
int c;
size_t k =0;
while ((c = getchar()) != EOF)
{
for(k=0; k < strlen(s);k++)
{
if(c == s[k])
{
c = news[k];
}
}
putchar(c);
}
}