[C con Clase] dividir un String
Abel
aydabella en yahoo.com.ar
Mie Abr 22 07:58:59 CEST 2009
Hola, podria ayudarme alguien con este código:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void split (const char* pInput, const char* pOut1, const char* pOut2) ;
int main(void)
{
char s1[100]="", s2[100]="";
split ("Hallo Welt", s1, s2);
printf ("%s\n", s1);
printf ("%s\n", s2);
return EXIT_SUCCESS;
}
void split (const char* pInput, const char* pOut1, const char* pOut2)
{
const char*p = strchr (pInput, ' ');
if (!p)
{
// input contains no ' '
*pOut1 = '\0';
*pOut2 = '\0';
}
else
{
strncpy (pOut1, pInput, p - pInput);
strcpy (pOut2, p + 1);
}
}
Me dá los siguientes errores:
Assigment to const location
Assigment to const location
Type error in argument 1 to 'strncpy';found 'pointer to const char' expected 'pointer to char'
Type error in argument 1 to 'strncpy';found 'pointer to const char' expected 'pointer to char'
Gracias por toda respuesta.
Abel
Más información sobre la lista de distribución Cconclase