Click here to Skip to main content
15,905,781 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Struggling with Regex Pin
DimkaSPB3-Nov-03 7:32
DimkaSPB3-Nov-03 7:32 
GeneralRe: Struggling with Regex Pin
Michael Dunn3-Nov-03 7:41
sitebuilderMichael Dunn3-Nov-03 7:41 
Generaldumb question Pin
K. Shaffer3-Nov-03 5:19
K. Shaffer3-Nov-03 5:19 
GeneralRe: dumb question Pin
David Crow3-Nov-03 5:23
David Crow3-Nov-03 5:23 
GeneralRe: dumb question Pin
Michael Dunn3-Nov-03 5:27
sitebuilderMichael Dunn3-Nov-03 5:27 
GeneralRe: dumb question Pin
K. Shaffer3-Nov-03 5:37
K. Shaffer3-Nov-03 5:37 
GeneralRe: dumb question Pin
Maxwell Chen3-Nov-03 16:47
Maxwell Chen3-Nov-03 16:47 
GeneralRe: dumb question Pin
Alton Williams5-Nov-03 0:26
Alton Williams5-Nov-03 0:26 
The problem is in your code

kshaff03 wrote:
void parse(const int size)
{
char buffer[size];
...
}


The problem lies in the way you've declared the array.

since char buffer[] is a static array meaning the compiler needs to know at compile time so it knows how much memory to allocate.
You're using a variable to size it. Where you should a constant or literal.
e.g.
#define MAX 100<br />
const unsigned int size = 50;<br />
<br />
inr main(void)<br />
{<br />
char foo[MAX];<br />
char bar[size];<br />
int fred[20];<br />
}


these 3 are all legal
your example should be coded as follows
void parse(const unsigned int &size)
{
char *buffer = new char[size];

...
delete[] buffer;
}

I'll send you an e-mail shortly
GeneralMDI application &amp; DLLs Pin
mfcbeginer3-Nov-03 5:06
mfcbeginer3-Nov-03 5:06 
GeneralSerialization questions Pin
Alton Williams3-Nov-03 4:35
Alton Williams3-Nov-03 4:35 
GeneralRe: Serialization questions Pin
Steve S3-Nov-03 22:59
Steve S3-Nov-03 22:59 
GeneralOverloading the &lt;&lt; and &gt;&gt; operators CArchive Pin
Alton Williams3-Nov-03 4:27
Alton Williams3-Nov-03 4:27 
GeneralRe: Overloading the &lt;&lt; and &gt;&gt; operators CArchive Pin
Steve S3-Nov-03 22:55
Steve S3-Nov-03 22:55 
GeneralRe: Overloading the &lt;&lt; and &gt;&gt; operators CArchive Pin
Alton Williams3-Nov-03 23:20
Alton Williams3-Nov-03 23:20 
GeneralRe: Overloading the &lt;&lt; and &gt;&gt; operators CArchive Pin
Steve S4-Nov-03 0:58
Steve S4-Nov-03 0:58 
GeneralCDataGrid Pin
Alton Williams3-Nov-03 4:22
Alton Williams3-Nov-03 4:22 
QuestionHow to use UniCode Pin
Member 4580153-Nov-03 3:19
Member 4580153-Nov-03 3:19 
AnswerRe: How to use UniCode Pin
Joe Woodbury3-Nov-03 5:45
professionalJoe Woodbury3-Nov-03 5:45 
GeneralOpening Bookmarked HTML files Pin
John Ulvr3-Nov-03 3:11
John Ulvr3-Nov-03 3:11 
GeneralRunning CScript.exe via CreateProcess Pin
Gary Wheeler3-Nov-03 2:16
Gary Wheeler3-Nov-03 2:16 
GeneralRe: Running CScript.exe via CreateProcess Pin
David Crow3-Nov-03 4:32
David Crow3-Nov-03 4:32 
GeneralRe: Running CScript.exe via CreateProcess Pin
Gary Wheeler3-Nov-03 5:08
Gary Wheeler3-Nov-03 5:08 
GeneralRe: Running CScript.exe via CreateProcess Pin
David Crow3-Nov-03 5:20
David Crow3-Nov-03 5:20 
GeneralRe: Running CScript.exe via CreateProcess Pin
Gary Wheeler3-Nov-03 7:10
Gary Wheeler3-Nov-03 7:10 
GeneralRe: Running CScript.exe via CreateProcess Pin
Michael Dunn3-Nov-03 5:39
sitebuilderMichael Dunn3-Nov-03 5:39 

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.