0

I need to edit every character of a string for an assignment; apply a simple Caesar cipher on it. What is the C equivalent of "charAt()"? I remember my prof saying that all strings are terminated with a certain character in C and that you could run a while loop till that character, but I'm not sure how to do it.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by shakunni
0

C string is an array of characters. You may set or get a character at specific index.

char str[20]="ABC";
str[0]='a'; // replace 'A' with 'a'

C String (char array) is terminated with a '\0' (null) character.

char str[20]="Sample Text";
 int i=0;
 while(str[i]!='\0') {
     /* put your code */
    i++;
 }

Edited by __avd: n/a

0

C string is an array of characters. You may set or get a character at specific index.

char str[20]="ABC";
str[0]='a'; // replace 'A' with 'a'

C String (char array) is terminated with a '\0' (null) character.

char str[20]="Sample Text";
 int i=0;
 while(str[i]!='\0') {
     /* put your code */
    i++;
 }

Thanks. I ended up doing something similar.

This question has already been answered. 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.