o18_99_1 2023-06-08 16:30 采纳率: 44.4%
浏览 34
已结题

vs code终端不能输出中文


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct Test9
{
    char name[50];
    int id;
    struct Test9* Nest;
}Test;

//头节点
Test* createhead(){
    Test* head = (Test*)malloc(sizeof(Test));
    head->Nest = NULL;
    return head;
}

//初始化节点
Test* createNode(char* name,int n){
    Test* newNode = (Test*)malloc(sizeof(Test));
    strcpy(newNode->name,name);
    newNode->id = n;
    newNode->Nest = NULL;
    return newNode;
}

//创建链表
Test* create(Test* head,int n){     //n为节点数
    Test* p = head;
    int i = 0;
    char address[20];
    printf("请输入张敏北京一日游观光的地点:");
    while(i<n){
        i++;
        scanf("%s",&address);
        Test* Node = createNode(address,i);
        p->Nest = Node;
        p = Node;
    }
    return p;
}
//输出链表
void printLink(Test* head,int n){
    Test* p = head;
    while (p ->Nest != NULL)
    {
        printf("the NO%d member is:\n",p->Nest->id);
        printf("地点是:%s\n",p->Nest->name);
        printf("第%d个参观\n",p->Nest->id);
        printf("\n");
        p = p->Nest;
    }
}

int main()
{
    int n = 3;
    Test* link = createhead();
    create(link,n);
    printLink(link,n);
    return 0;
}

vs code终端不能输出中文,

  • 写回答

3条回答 默认 最新

  • 少林and叔叔 2023-06-08 16:37
    关注

    在vscode的设置里,将编码方式修改为UTF-8,就能显示中文了。
    file->preferences->settings,然后按下图设置:

    img

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 8月25日
  • 已采纳回答 8月17日
  • 创建了问题 6月8日