Click here to Skip to main content
15,881,882 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to parse HL7 message in VC++ Pin
Stuart Dootson18-Apr-09 0:31
professionalStuart Dootson18-Apr-09 0:31 
GeneralRe: How to parse HL7 message in VC++ Pin
Abhijit D. Babar18-Apr-09 1:05
Abhijit D. Babar18-Apr-09 1:05 
GeneralRe: How to parse HL7 message in VC++ Pin
Stuart Dootson18-Apr-09 1:07
professionalStuart Dootson18-Apr-09 1:07 
GeneralRe: How to parse HL7 message in VC++ Pin
Abhijit D. Babar18-Apr-09 1:40
Abhijit D. Babar18-Apr-09 1:40 
GeneralRe: How to parse HL7 message in VC++ Pin
Stuart Dootson18-Apr-09 1:50
professionalStuart Dootson18-Apr-09 1:50 
GeneralRe: How to parse HL7 message in VC++ [modified] Pin
Abhijit D. Babar18-Apr-09 3:05
Abhijit D. Babar18-Apr-09 3:05 
GeneralRe: How to parse HL7 message in VC++ Pin
Stuart Dootson18-Apr-09 5:08
professionalStuart Dootson18-Apr-09 5:08 
QuestionSplit string into substrings Pin
Manfr3d17-Apr-09 21:12
Manfr3d17-Apr-09 21:12 
Hello guys,

I want to split a string into substrings using strtok(). The code is
#include "stdafx.h"

#using <mscorlib.dll>
#include <iostream>
#include <string>
#include <stdio.h>

using namespace System;
using namespace std;

char str2list(char* str, char** list, const char* delimiters)
{
	for (char c = 0; c < sizeof(list) / sizeof(char*); c++)
	{
		list[c] = strtok(str, delimiters);
		if (list[c] == NULL) break;
	}
	return c;
}

int _tmain()
{
	char** arglist;
	arglist = new char*[16];
	char* exmp = "I have a problem!";
	str2list(exmp, arglist, " ");
	for (char c = 0; c < sizeof(arglist) / sizeof(char*); c++)
	{
		cout << arglist[c] << endl;
	}
	delete[] arglist;
	return 0;
}
</stdio.h></string></iostream></mscorlib.dll>

When I try to execute the program a runtime error occurs saying that there is a null-reference exception in the line list[c] = strtok(str, delimiters);. To ensure that there is enough free memory I even used the new operator.
Does anyone have an idea why this doesn't work?

Thanks and best wishes.
AnswerRe: Split string into substrings [modified] Pin
Stuart Dootson17-Apr-09 21:56
professionalStuart Dootson17-Apr-09 21:56 
GeneralRe: Split string into substrings Pin
Manfr3d18-Apr-09 5:04
Manfr3d18-Apr-09 5:04 
GeneralRe: Split string into substrings Pin
Stuart Dootson18-Apr-09 5:14
professionalStuart Dootson18-Apr-09 5:14 
QuestionHow do I develop an internet video conferencing system like skype? Pin
Hiigara17-Apr-09 11:16
Hiigara17-Apr-09 11:16 
AnswerRe: How do I develop an internet video conferencing system like skype? Pin
Divyang Mithaiwala17-Apr-09 19:40
Divyang Mithaiwala17-Apr-09 19:40 
AnswerRe: How do I develop an internet video conferencing system like skype? Pin
zhanzongru19-Apr-09 1:20
zhanzongru19-Apr-09 1:20 
QuestionDLL Processing Speed, Pin
ScotDolan17-Apr-09 8:55
ScotDolan17-Apr-09 8:55 
AnswerRe: DLL Processing Speed, Pin
Stuart Dootson17-Apr-09 9:04
professionalStuart Dootson17-Apr-09 9:04 
AnswerRe: DLL Processing Speed, Pin
Luc Pattyn17-Apr-09 11:26
sitebuilderLuc Pattyn17-Apr-09 11:26 
QuestionDo loop while waiting for a component event Pin
digitalni17-Apr-09 8:22
digitalni17-Apr-09 8:22 
AnswerRe: Do loop while waiting for a component event Pin
Stuart Dootson17-Apr-09 8:48
professionalStuart Dootson17-Apr-09 8:48 
GeneralRe: Do loop while waiting for a component event Pin
digitalni17-Apr-09 9:20
digitalni17-Apr-09 9:20 
GeneralRe: Do loop while waiting for a component event Pin
Stuart Dootson17-Apr-09 9:35
professionalStuart Dootson17-Apr-09 9:35 
QuestionBaes/Derived Class Question Pin
ForNow17-Apr-09 7:04
ForNow17-Apr-09 7:04 
AnswerRe: Baes/Derived Class Question Pin
CPallini17-Apr-09 7:11
mveCPallini17-Apr-09 7:11 
AnswerRe: Baes/Derived Class Question Pin
led mike17-Apr-09 7:21
led mike17-Apr-09 7:21 
GeneralRe: Baes/Derived Class Question Pin
ForNow17-Apr-09 12:32
ForNow17-Apr-09 12:32 

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.