Profetas wrote on 25/07/04 :
does this function exist in c? on any equivalent? that convert string to
integer?
how do I convert a array to a "string"
example
char arr['a','b','c'];
This is not C.
char arr[] = {'a','b','c'};
But it's not a string.
char *arr2;
how can I make arr2 = arr ?
arr2 is just a pointer. You are allowed to make it point to an array f
char, but it doesn't make it a string.
Bare in mind that in C, '=' is the affectation operator, and that '=='
is the equal operator (works with numerical values)
If you want to build a string with the caracters of the array of char,
you can do this :
/* allocate room enough */
size_t const len = sizeof arr;
char *arr2 = malloc (len + 1); /* <stdlib.h> */
if (arr2 != NULL)
{
/* make the string */
*arr2 = 0;
strncat (arr2, arr, len);
<...>
/* when finished */
free (arr2), arr2 = NULL;
}