0
char ch[] = {'7', '3', '0', '8'};
int [] nums[2];
void transformInt(char [] c1) {
int n1[2];
int j = 0;
for (j = 0; j < 10; j++ ) {
if (c1[j] != '0') {
n1[j] = c1[j];
} else break;
return n1;
}
}
Guys, I need to turn a char vector into an int vector, but I can’t. In this case, 0 would separate the two values. Thus, n1[0] would need to be equal to 73 and n1[1] equal to 8. I tried to create a method, but it does not even work to allocate the first value, I do not know what is wrong. Nor do I know how to return a vector method.
What is this array also? It would not be the case that you build a new array until you find a character '0' and then use the strtol function of <stdlib. h> to convert the string to an integer?
– anonimo
In this case, my difficulty is to build the new array until I find zero.
– Corá
The array tam was wrong, it was to be C1
– Corá
your code has syntax errors, nor compiles...take out at least the syntax errors and try to run the program
– zentrunix
I edited the question by placing spaces...use spaces to separate operators (+, =, -, etc) and keys ({}), otherwise it becomes very difficult to understand when everything is stuck together
– zentrunix
int [] nums[2]; this is not valid C
– user3629249