A function returns an aray of integers and I want it to pass to another function which searches for some pattern. But the second function expects a string.
Example:
int IArray = ...
|
Please, look at the following code that just convert an unsigned int to a string (there may be some unhandled cases but it's not my question), allocating a char array ... |
I'm beginner in C.
I have an char array in this format for example "12 23 45 9".
How to convert it in int array {12,23,45,9}?
... |
I have a JSON string and I want to convert it into an Array of integers. I have a JSON parser, but I am not able to understand how to achieve ... |
I am trying to set a variable name and variable value in the environment of Windows by using this function
void env_add(char varname[], char varvalue[]) {
}
The problem is that i do not ... |
The subscript you're using in the atoi call is derefferencing the pointer. You should use pointer arithmetic in order to pass the actual pointer. e.g. ar[i] is a value while (ar + i) is a pointer. AHHHHH I see! that works alot better than the way i was doing it :P Thank you sooooo much! one more quick question though, I ... |
|
|
I am a beginner and have some confusion with respect to pointers and strings. It seems that the pointers with dealing with integer arrays behave differently, as opposed to strings. Can some one explain me the difference? Sample Program: int main() { int array[]={1,2,3,4,5}; char array1[]={"Name is Max"}; int *ptr; char *ptr1; ptr=array; ptr1=array1; cout<<"The array is "< |
|
|
I'm doing an assignment for a C course I am in. For part of the assignment I am loading integers that are specified in a string of characters into an array. For example, if I have this string: "1,5-7,12" I want to load the numbers 1, 5, 6, 7, 12 into an array of integers. I could probably do this with ... |
HI! I have a 2D array. It is 20 columns of 20 ints (20x20).It contains only values from 0 to 9. I am/have been attempting to use this 2D array of int to initialise a 20x21 array of char. I also want to replace the associated integer (0 to 9) with a corresponding character ('A' to 'J'). ie) A = 0 ... |
Most of my experience has been in MATLAB in alg development and system simulation and as such I have limited experience in handling types and memory (which MATLAB looks after for me) I'm now in the process of programming networked wireless microcontrollers which will feed data into MATLAB (this part works). I do need to run write come c to run ... |
im sure this has been answered before on here, however after searching using the keyword 'convert' and going through half an hours worth of replies my question wasnt answered. im trying to convert a char array ( of numbers like [7][2][6][4][5][6]) to one whole integer like 726456 (decimal) (which have been converted from ascii to dec) so i can perform maths ... |
Ok I finally got my program to read in a line as a character array for a string but now I want to convert that character array into an integer array. Its like this: if I input 1 2 3 4 5 I want to put that into an integer array with a[0]=1, a[1]=2, etc. Or if I have this: 12 ... |
Thanks Jim thats works great. Its schoolwork (youve helped me before and asked the same question!) How about passing this string to another function as in the following, at the moment I get a thread error when the program runs (not enough memory i guess) Is the input to the function correct, ie type char???? Do you know how i can ... |
i have a string of numbers as chars eg 15 7 4 0 2 6 0 including the spaces in a variable and i need to place the numbers into an integer array such that: int[0] == 15 , int[1] == 7 , int[2] == 4 and so on. How do i do this? ps in C not C++ |
|
|
#include #include void stringFormat ( int nums ); int main ( void ) { stringFormat ( 143 ); /*test*/ getchar(); return 0; } void stringFormat ( int nums ) { int numbers[nums]; int i; for ( i = 0; i < nums; i++ ) { numbers[i] = 1; printf ( "%d", numbers[i] ); } } |
|
Hello, Ok.. here is another problem I have come up with.. I have a string of numbers (comma or '\n' separated (from .csv file)). I have allocated an array of integers to put in the numbers into yet how do I actually do it. Example: I have "13, 34, 23, 12\n" string and my program should transform it into a[0]=13; a[2]=34; ... |