字符串到ASCII的问题

时间:2019-05-19 17:14:06

标签: c arrays string types

我正在尝试将字符串转换为ASCII以进行练习。但是我没有什么问题。我尝试打字,但是没有用。我的输出仍然为空。这是我的代码:

#include <stdio.h>

#define LIMIT 100
#define SENTINEL quit

typedef struct{
    char input[LIMIT];
    char output[LIMIT];
} message;

char crypt(message text);

int main(){
    message text;
    int numVal;

    printf("Enter the message> ");
    gets(text.input);
    crypt(text);
    printf("Crypted message is> %s", text.output);
    return 0;
}

char crypt(message text){
    int numVal[LIMIT];

    for (int i = 0; i < LIMIT; i++) {
        while (text.input[i] != '\0') {
            numVal[i] = text.input[i];
            i++;
        }
        text.output[i] = numVal[i] + 6;
    }
    return text.output;             
}

我认为功能部分存在问题。我尝试打字,但没有奏效,我的输出仍然为空。

0 个答案:

没有答案