问答详情
源自:6-1 数组初体验

大神,江湖救急

在敲printf时候,字符串那个位置该怎么表示,字符串后面表示地址那个位置该怎么敲代码

提问者:qq_龍犇_04248178 2016-10-20 19:21

个回答

  • 越飞越高
    2016-10-24 18:33:35

    输出字符串:printf("%s\n",str);

    例如:

    #include<stdio.h>
    struct student{
    char a[20];
    char id[20];
    };
    int main(void)
    {
    struct student str;
    printf("请输入一个字符串:");
    scanf("%s",str.a);
    printf("输入的字符串是:");
    printf("%s\n\n",str.a);
    }

  • 諵沫
    2016-10-21 17:46:31

    字符串直接打在引号里面就行,假如需要输出变量,直接用格式符  逗号  变量