小编sni*_*117的帖子

无法理解如何从C中的函数返回字符串

    void add()
    {    
    char name[50], surname[50], usern[50];

    int id, birth, amount;
    printf("Enter your name, surname and your year of birth:\n");
    scanf("%s %s %d", &name, &surname, &birth);
    printf("Enter your ID, username and your total amount:\n");
    scanf("%d %s %d", &id, &usern, &amount);
    const char *pass1=function(usern);  
    }

  const char *function (char usern[50])
  {
    char temp;
    int i=0;
    int j;
    j = strlen(usern) - 1;
    while (i < j) 
    {
      temp = usern[i];
      usern[i] = usern[j];
      usern[j] = temp;
      i++;
      j--;
    }
    return usern; …
Run Code Online (Sandbox Code Playgroud)

c string pointers function

0
推荐指数
1
解决办法
93
查看次数

标签 统计

c ×1

function ×1

pointers ×1

string ×1