2015-11-28 139 views
-3

我想从键盘得到一个字符串,如“abcde”,然后将其插入一个字符,例如b是char,但没有函数,如atoi(a)for整数。字符串与函数字符

#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 

int main(){ 
    char a[6]; 
    char b; 
    scanf("%s",a); 
    printf("%s",a); 
    printf("\n"); 
    b=a; 
    printf("%c",b); 

    return 0; 
} 
+0

heh? whaddya的意思是插入一个字符串到char? –

+2

'b = a [0]'而不是'b = a' – BLUEPIXY

+0

字符串“abcde”不是数字。你能澄清你的意思吗? – this

回答

1

您不能在字符中插入字符串。但是,您可以将该字符串转换为一个字符数组。如果这是你正在寻找的,请参阅this answer