is there anything similar to Java's string 'charAt()' Method in C?

后端 未结 3 1825
清酒与你
清酒与你 2021-01-22 15:07

I\'m trying to convert a piece of code from Java to C and I got stuck here, trying to get a character at each position.

char ch;

line += \' \';
    while (pos          


        
3条回答
  •  有刺的猬
    2021-01-22 15:46

    You can access the values as though the String was an array.

    char str[] = "Hello World";
    printf("%c", str[0]);
    

提交回复
热议问题