Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 将非常大的字符串转换为整数格式_C_String - Fatal编程技术网

C 将非常大的字符串转换为整数格式

C 将非常大的字符串转换为整数格式,c,string,C,String,我在输入中有一个200个字符的字符串(所有字符都是0或1)。需要一种将字符转换为int格式并将其存储在数组或变量中的方法 示例:“001011110010…”->001011110010… 下面的代码片段仅适用于 for(无符号j=0;j

我在输入中有一个200个字符的字符串(所有字符都是0或1)。需要一种将字符转换为
int
格式并将其存储在数组或变量中的方法

示例:
“001011110010…”->001011110010…

下面的代码片段仅适用于
for(无符号j=0;j}
int无法存储200位数字,加上0001将被转换为1,可能一个字节数组是您应该使用的,这就是我在代码中选择数组的原因。我之前在代码中尝试过类似的方法,但那里出现了故障。现在,在您的代码/帮助下,它开始工作了。感谢使用lotUse
'0'
而不是literal 48。ASCII很有可能,但不能保证IIRC,加上幻数是不好的。
    scanf("%u", &digit_num);   //number of digits in input number/string
    unsigned input_binary[digit_num]; //where the integers will be stored as individual digit
    unsigned long long temp; //temporary storage
    char crc[digit_num+1], *ptr=NULL;
    scanf(" %s", crc);
    temp=strtoull(crc,&ptr,10);
    for (unsigned j = 0; j < digit_num; j++)
    {
        input_binary[digit_num-j-1]=temp%10;
        temp/=10;
    }