I'm a C newbie, but a little more experienced in Perl. In Perl, what I want to do would be done like this...
That's where I'm coming from, but I need to do this in C. I've devised a way but I'm wondering if there's a better way than this...
Stuff happens in between some of those lines of code, but I've put the important lines.
Any ideas?
Thank you.
--
-- GhodMode
Code:
my $external_id = ($data[$row][1] =~ s/^0+(.*)$/$1/);
That's where I'm coming from, but I need to do this in C. I've devised a way but I'm wondering if there's a better way than this...
Code:
data[row][1] = (char*)malloc(11); /* Account # */
/* stuff */
strncat( data[row][1], line + 6, 10 );
/* stuff */
char external_id[48] = "";
/* stuff */
char holdvar[48] = "";
/* stuff */
strncpy( holdvar, data[row][1], 48 );
for ( i = 0; i < strlen(holdvar); i++ )
{
if ( holdvar[i] == '0' )
{
continue;
}
while ( i < strlen(holdvar) )
{
sprintf( external_id, "%s%c", external_id, holdvar[i++] );
}
}
Stuff happens in between some of those lines of code, but I've put the important lines.
Any ideas?
Thank you.
--
-- GhodMode