How can I get the nth character of a string?

前端 未结 3 2056
暗喜
暗喜 2020-12-09 17:00

I have a string,

char* str = \"HELLO\"

If I wanted to get just the E from that how would I do that?

3条回答
  •  执笔经年
    2020-12-09 17:45

    You would do:

    char c = str[1];
    

    Or even:

    char c = "Hello"[1];
    

    edit: updated to find the "E".

提交回复
热议问题