c语言获取字符串的第几个字符
#include<stdio.h> int main() { char* str = "HELLO"; char c = str[0]; printf("str[0]:%c\n", c); char d = "Hello"[1]; printf("\"Hello\"[1]:%c\n", d); }
test# gcc hello.c test# ./out str[0]:H "Hello"[1]:e
#include<stdio.h> int main() { char* str = "HELLO"; char c = str[0]; printf("str[0]:%c\n", c); char d = "Hello"[1]; printf("\"Hello\"[1]:%c\n", d); }
test# gcc hello.c test# ./out str[0]:H "Hello"[1]:e