atoi

    1热度

    4回答

    我已经从GPS接收器解析了一些日期和时间。并且需要将它们从字符串转换为int: char year[4] = "2014"; char month[2] = "01"; char day[2] = "24"; char hour[2] ="12"; char minute[2] = "58"; char second[2] = "39"; GPS_current_year = ato

    3热度

    2回答

    所有的迹象告诉我这是一个可笑的简单问题来解决,但我不知道错误告诉我atoi函数不存在。 C++ #include <iostream> #include <stdlib.h> using namespace std; string line; int i; int main() { line = "Hello"; i = atoi(line); co

    1热度

    3回答

    基本上,我试图将一堆char输入转换为int,并将它们分配给一个动态int数组。字符串输入和标记化似乎工作正常。这个问题(从我可以告诉的)似乎是重新分配int数组; 数组重新分配两次后,指向int数组的指针返回NULL。 我试图做的是每当令牌的数量达到或超过(大小除以sizeof(int))时,int数组的大小加倍。每当满足这个条件时,realloc语句就起作用。 我认为使用指针指针是最终的解决方

    20热度

    1回答

    需要从十六进制表示字符串中产生int,如"0xFA"或更好"FA"。需要类似atoi("FA")。有没有什么标准的解决方案?

    -1热度

    6回答

    我的输出:6 123456 44 0 67 87 0 我想是这样的输出:10 123456 44 0 67 87 0 0 45 55 88 为什么我的程序没有打印所有的整数?任何人都可以请帮我检查我的代码有什么问题吗?我应该对我的代码做些什么改变?这是我的代码。 #include <stdio.h> #include <string.h> #include <ctype.h> #includ

    0热度

    3回答

    我想设置一个指针(processNum)等于一个普通的int(processNumTemp)。我怎样才能做到这一点?我试着只做processNum = processNumTemp,因为我试图设置一个等于非指针的指针,所以会出现错误。我该如何做这项工作?下面是我的代码: int *processNum = (int *)malloc(sizeof(12)); int processNum

    0热度

    1回答

    我遇到的atoi)一个奇怪的问题( 我做一个转换是这样的: cout<<atoi(mystring.c_str())<<endl; MyString的是像3245524字符串 上面的代码只会返回3到标准输出。 现在,如果我使字符串变小,例如少于1000000,然后我得到整个号码返回到标准输出。 任何想法是什么导致这个问题?这仍然远低于C++ int的限制,所以它不会溢出。 编辑,一些额外的信息

    2热度

    2回答

    这是我此刻的功能 long long int File::Getline3(int user1, long long int user3) { std::string filename = std::to_string(user1); std::ifstream fin(filename + ".txt"); fin.getline (line1, 5); fin.getline (l

    -1热度

    3回答

    下面是一个简单的程序,它汇总了命令行中发送的所有数字。它应该采取任意数量的值。 它不断给我一个0每行。我已经厌倦做一些改变,但它仍然给出相同的输出 #include <iostream> #include <cstdlib> using namespace std; int main(int argc, char *argv[]) { for (int i = 0; i <

    0热度

    3回答

    我有这样的代码,但这里的atoi完全不 工作,如果我给基地址,然后还它会导致概率 int main() { char *token; int value; char data = "23+100"; int i = 0; while(data[i] != '+') { value = atoi(data[i]);