Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wacky variable problem

Status
Not open for further replies.

carlg

Programmer
Jun 23, 2004
88
US
Please see code

Code:
int InsertCCharge (CCharge cc)
{
    char cust_as_str[10];
    char chid_as_str[10];

    memset (cust_as_str, '\0', sizeof(cust_as_str));
    memset (chid_as_str, '\0', sizeof(chid_as_str));

    /*sprintf (chid_as_str, "%d", cc.cc_ch_id);*/
    strcpy (chid_as_str,  "sdfd");
    sprintf (cust_as_str, "%d", cc.cc_cust);
    printf ("IT IS %d\n", cc.cc_ch_id);
    printf ("IT IS %s\n", chid_as_str);
    printf ("CUST IS %d\n", cc.cc_cust);
    printf ("CUST2 IS %s\n", cust_as_str);
    return(0);
}



When I print out cust_as_str on the last line

Why in the world would it be blank. The other 3 that I print out are populated

I tryed populating this variable with sprintf and then I used strcpy and cannot get a value in it

This is driving me nuts

Please help

THanks

Carl
 
OK, I got it

Thanks anyway

There was another variable (that's not shown)

I increased it's size from 10 to 15.

It must have been somehow overwriting the other var.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top