Click here to Skip to main content
15,898,035 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Read 1000 Lines from text file in a single shot ........ Pin
David Crow11-Aug-09 8:56
David Crow11-Aug-09 8:56 
QuestionHow to set a PDF fields? Pin
Hadi Dayvary11-Aug-09 6:21
professionalHadi Dayvary11-Aug-09 6:21 
AnswerRe: How to set a PDF fields? Pin
Bacon Ultimate Cheeseburger11-Aug-09 14:08
Bacon Ultimate Cheeseburger11-Aug-09 14:08 
GeneralRe: How to set a PDF fields? Pin
Hadi Dayvary11-Aug-09 20:13
professionalHadi Dayvary11-Aug-09 20:13 
GeneralRe: How to set a PDF fields? Pin
Hadi Dayvary11-Aug-09 20:14
professionalHadi Dayvary11-Aug-09 20:14 
GeneralRe: How to set a PDF fields? Pin
Bacon Ultimate Cheeseburger11-Aug-09 21:36
Bacon Ultimate Cheeseburger11-Aug-09 21:36 
GeneralRe: How to set a PDF fields? Pin
ThatsAlok11-Aug-09 22:19
ThatsAlok11-Aug-09 22:19 
Questiondelete [] problem, and extra char(s) showing up in substring? Pin
Mike the Red11-Aug-09 2:11
Mike the Red11-Aug-09 2:11 
int main() {
		char * lpszData = "file=abcdefg&info=&x=3&4=5";
		int count = 0;
		char * pt = strchr(lpszData, '&');
		while ( pt != NULL ) {
			count++;
			pt = strchr(++pt, '&');
		};
		cout << "Data: " << lpszData << "\n";
		cout << "Count: " << count << "\n\n";

		char ** split = new char * [count + 1];
		char * start = lpszData;

		for (int i = 0; i <= count; i++) {
			pt = strchr(start, '&');
			if ( pt == NULL )
				pt = lpszData + strlen(lpszData);
			split[i] = new char[pt - start + 1];
			strset(split[i], 0);
			strncpy(split[i], start, pt - start);

			start = pt + 1;
		};
		for (int i = 0; i <= count; i++) {
			cout << "split[" << i << "] = " << split[i] << "\n";
		};
		for (int i = 0; i <= count; i++)
			delete [] split[i];
		        
		delete [] split;

}
First, the delte [] split[i]; in the for loop at the end gives me an error, but when I remove this line the code leaks.

Second, the output is:
Data: file=abcdefg&amp;info=&amp;x=3&amp;4=5
Count: 3

split[0] = file=abcdefg
split[1] = info=[extended_char]3
split[2] = x=3
split[3] = 4=5
Try as I might I can't figure out where the extra characters are coming from in split[1].


Can anyone help with either of these problems?

Thanks for any assistance you can give,

MZR
AnswerRe: delete [] problem, and extra char(s) showing up in substring? Pin
CPallini11-Aug-09 2:26
mveCPallini11-Aug-09 2:26 
GeneralDeath is in the details... Thanks pallini! -nt- Pin
Mike the Red11-Aug-09 2:31
Mike the Red11-Aug-09 2:31 
GeneralYou are welcome. Pin
CPallini11-Aug-09 2:36
mveCPallini11-Aug-09 2:36 
AnswerRe: delete [] problem, and extra char(s) showing up in substring? Pin
David Crow11-Aug-09 2:53
David Crow11-Aug-09 2:53 
AnswerRe: delete [] problem, and extra char(s) showing up in substring? Pin
Cedric Moonen11-Aug-09 3:10
Cedric Moonen11-Aug-09 3:10 
Generalomfg -or- Thank you, Cedric Pin
Mike the Red11-Aug-09 4:03
Mike the Red11-Aug-09 4:03 
QuestionFSCTL_EXTEND_VOLUME fails Pin
Madan Chauhan11-Aug-09 1:30
Madan Chauhan11-Aug-09 1:30 
QuestionReturn value of a MFC Dialog Box Applicatin.. Pin
Member 383463011-Aug-09 1:02
Member 383463011-Aug-09 1:02 
AnswerRe: Return value of a MFC Dialog Box Applicatin.. Pin
Cedric Moonen11-Aug-09 1:10
Cedric Moonen11-Aug-09 1:10 
QuestionRe: Return value of a MFC Dialog Box Applicatin.. Pin
CPallini11-Aug-09 1:49
mveCPallini11-Aug-09 1:49 
QuestionRe: Return value of a MFC Dialog Box Applicatin.. Pin
Maximilien11-Aug-09 2:39
Maximilien11-Aug-09 2:39 
QuestionRe: Return value of a MFC Dialog Box Applicatin.. Pin
CPallini11-Aug-09 2:54
mveCPallini11-Aug-09 2:54 
AnswerRe: Return value of a MFC Dialog Box Applicatin.. Pin
Maximilien11-Aug-09 2:59
Maximilien11-Aug-09 2:59 
GeneralRe: Return value of a MFC Dialog Box Applicatin.. Pin
CPallini11-Aug-09 3:10
mveCPallini11-Aug-09 3:10 
GeneralRe: Return value of a MFC Dialog Box Applicatin.. Pin
Member 383463011-Aug-09 4:04
Member 383463011-Aug-09 4:04 
GeneralRe: Return value of a MFC Dialog Box Applicatin.. Pin
CPallini11-Aug-09 4:49
mveCPallini11-Aug-09 4:49 
AnswerRe: Return value of a MFC Dialog Box Applicatin.. Pin
wmallory11-Aug-09 5:50
wmallory11-Aug-09 5:50 

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.