Click here to Skip to main content
15,890,690 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRoom for improvement let me know. Pin
jkirkerx8-Dec-11 13:16
professionaljkirkerx8-Dec-11 13:16 
QuestionParsing in C Pin
Software20077-Dec-11 6:55
Software20077-Dec-11 6:55 
AnswerRe: Parsing in C Pin
Albert Holguin7-Dec-11 7:23
professionalAlbert Holguin7-Dec-11 7:23 
AnswerRe: Parsing in C Pin
Chris Losinger7-Dec-11 8:10
professionalChris Losinger7-Dec-11 8:10 
GeneralRe: Parsing in C Pin
Software20077-Dec-11 9:54
Software20077-Dec-11 9:54 
QuestionRe: Parsing in C Pin
David Crow7-Dec-11 9:27
David Crow7-Dec-11 9:27 
AnswerRe: Parsing in C Pin
Software200710-Dec-11 13:28
Software200710-Dec-11 13:28 
AnswerRe: Parsing in C Pin
Software200712-Dec-11 5:52
Software200712-Dec-11 5:52 
I have one more question C- related:
C++
char *getLine(char *p, char *out)
{
   int Dees = 0;
   char *px = p;
   p++;   //advance to where we think there is '('
 
   if (*p!='(') return NULL; // error
 
   int paren_count = 1;
 
   while (*px)
   {
                   if(*px=='d')
                   {
                                   Dees++;
                                   if(Dees >1 && *(px+1)=='(') //Done at 2nd 'd'
                                      break;
                   }
 
       *out = *px; // copy
       out++; px++; // next
   }
   return px;
}

//main program
  char *px="d(text)n(0)l(1)d(text2)n(1)l(2)...";
  char line[8192];
  char *py = getLine(px,line);


In the main program, after calling the function getLine(), I do get line correctly as in "d(text)n(0)l(1)" but filled with garbage after that as its trying to fill out 8192 characters. How do I make it not fill the rest of the unused space. Note, I don't know the size of "line" as it varies, but I need it big enough. I know strcpy could be useful here somewhere, just can't get it to work.

I also tried in getLine() the following:
char field[4095];
 strcpy(field,out);

But nothing gets copied, out shows null in the debugger.


Thanks

modified 12-Dec-11 12:00pm.

AnswerRe: Parsing in C Pin
David Crow12-Dec-11 7:15
David Crow12-Dec-11 7:15 
GeneralRe: Parsing in C Pin
Software200712-Dec-11 7:32
Software200712-Dec-11 7:32 
SuggestionRe: Parsing in C Pin
David Crow12-Dec-11 8:34
David Crow12-Dec-11 8:34 
GeneralRe: Parsing in C Pin
Software200712-Dec-11 9:36
Software200712-Dec-11 9:36 
QuestionDouble value precision Pin
mutpan6-Dec-11 18:54
mutpan6-Dec-11 18:54 
AnswerRe: Double value precision Pin
Chandrasekharan P6-Dec-11 19:27
Chandrasekharan P6-Dec-11 19:27 
GeneralRe: Double value precision Pin
mutpan6-Dec-11 19:35
mutpan6-Dec-11 19:35 
GeneralRe: Double value precision Pin
Chandrasekharan P6-Dec-11 20:33
Chandrasekharan P6-Dec-11 20:33 
AnswerRe: Double value precision Pin
CPallini6-Dec-11 22:13
mveCPallini6-Dec-11 22:13 
GeneralRe: Double value precision Pin
Albert Holguin7-Dec-11 3:24
professionalAlbert Holguin7-Dec-11 3:24 
AnswerRe: Double value precision Pin
tssutha036-Dec-11 22:30
tssutha036-Dec-11 22:30 
AnswerRe: Double value precision Pin
Chuck O'Toole7-Dec-11 5:03
Chuck O'Toole7-Dec-11 5:03 
AnswerRe: Double value precision Pin
JackDingler9-Dec-11 9:30
JackDingler9-Dec-11 9:30 
AnswerRe: Double value precision Pin
Chuck O'Toole9-Dec-11 10:38
Chuck O'Toole9-Dec-11 10:38 
GeneralRe: Double value precision Pin
JackDingler9-Dec-11 10:42
JackDingler9-Dec-11 10:42 
AnswerRe: Double value precision Pin
Chuck O'Toole9-Dec-11 16:52
Chuck O'Toole9-Dec-11 16:52 
QuestionAccess ODBC issue/question in MFC Application CDatabase Class Pin
MacRaider46-Dec-11 9:06
MacRaider46-Dec-11 9:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.