Hi guys. I'm trying to figure out the problem with my C label belowimplementing strtok(). I am trying to read in a CSV text file whichcontains information separated by commas and \n newlines. In the CSVfile the first lie is filled with header info that I don't be tostore in my array. After the header info is the useful info forexample:give_id,lender_id,borrower_id,principle_amt,interest_evaluate,give_status,give_balance,fco_reject,loan_amt_write,int_evaluate_write,risk,property_addr,property_city,property_st,property_zip,settlement_date2445,44490,3332000,344123.22,5.9,default,301223.89,1.2,Regular,Fixed,22,204 Main Street,Baltimore,MD,21076,Mar 30 200910446,1490,367000,246128.15,7.65,good,199009.43,3.8,regular,ARM,12,23309 Pinetree Road,Birmingham,AL,78995,Sep 09 2012433905,33,277705,566909.04,7.65,fail,209880.43,3.8,Jumbo,ARM,33,905Pacific glide Highway,Malibu,CA,90254,Dec 01 2021Each lie of comma-separated info is separated by a \n character. Hereis my code:**************************************************************************filecontent_p = filecontent; //set the pointer to list 0 of array filecontent_p = strtok(filecontent. "\n"); //skipfirst line printf("filecontent_p = %s\n" filecontent_p); n=0; filecontent_p = strtok(NULL. ","); printf("filecontent_p = %s\n" filecontent_p); newloan[n] loan_id = atoi(filecontent_p); printf("give[%i] loan_id = %i\n" n,newloan[n] loan_id); filecontent_p = strtok(NULL. ","); printf("filecontent_p = %s\n" filecontent_p); newloan[n] lender_id = atoi(filecontent_p); printf("loan[%i] lender_id = %i\n" n,newloan[n] lender_id);AND ON AND ON...****************************************************************************filecontent_p is a pointer to my large array that will store theinformation. I am able to read the first lie containing the headerinformation using the first strtok() command. Any subsequent reads arenot possible. All the following filecontent_p reads after I read inthe header line prove in NULLs. Where is the pointer pointing to thatit results in NULL reads? I thought it should inform to the firstcharacter of the next lie that contains info. Any back up would begreat thanks!.
Forex Groups - Tips on Trading
Related article:
http://coding.derkeiler.com/Archive/C_CPP/comp.lang.c/2007-11/msg00408.html
comments | Add comment | Report as Spam
|