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

C / C++ / MFC

 
QuestionMost efficient way to create a string range in C? Pin
Member 1280348819-Oct-16 10:19
Member 1280348819-Oct-16 10:19 
AnswerRe: Most efficient way to create a string range in C? Pin
leon de boer19-Oct-16 19:33
leon de boer19-Oct-16 19:33 
AnswerRe: Most efficient way to create a string range in C? Pin
leon de boer20-Oct-16 21:14
leon de boer20-Oct-16 21:14 
AnswerRe: Most efficient way to create a string range in C? Pin
Joe Woodbury26-Oct-16 12:16
professionalJoe Woodbury26-Oct-16 12:16 
QuestionHow to invoke Printing Preferences for the given Printer programmatically? Pin
purnachandra505016-Oct-16 17:48
purnachandra505016-Oct-16 17:48 
SuggestionRe: How to invoke invoke Printing Preferences for the given Printer programmatically? Pin
Richard MacCutchan17-Oct-16 5:06
mveRichard MacCutchan17-Oct-16 5:06 
QuestionHelp please Memoized rod cutting in C while showing the length it is cut Pin
Member 1279667016-Oct-16 12:03
Member 1279667016-Oct-16 12:03 
AnswerRe: Help please Memoized rod cutting in C while showing the length it is cut Pin
leon de boer16-Oct-16 16:12
leon de boer16-Oct-16 16:12 
I am assuming your cut and paste failed because as that appears to me that would not compile the r line has no type

Anyhow your malloc is correct the problem is with r

1.) You can't and don't need the array specifier.
2.) You definitely don't dereference the malloc to it ... "*r" means dereference

Anyhow any quick check of creating a dynamic array would give you the correct syntax
int* r;
r = (int *) malloc ((n+ 1) * sizeof(int));

That will allocate n+1 integers holding the allocated array in pointer r.

To access them you then use r[x] where x is the index position in the array.

It's your responsibility to release the memory when you are done
free(r);

In vino veritas

GeneralRe: Help please Memoized rod cutting in C while showing the length it is cut Pin
Richard MacCutchan17-Oct-16 5:08
mveRichard MacCutchan17-Oct-16 5:08 
AnswerRe: Help please Memoized rod cutting in C while showing the length it is cut Pin
Richard MacCutchan16-Oct-16 21:25
mveRichard MacCutchan16-Oct-16 21:25 
QuestionAssigning pointers from one class to another and Pin
Vaclav_14-Oct-16 6:23
Vaclav_14-Oct-16 6:23 
AnswerRe: Assigning pointers from one class to another and Pin
leon de boer14-Oct-16 17:58
leon de boer14-Oct-16 17:58 
GeneralRe: Assigning pointers from one class to another and Pin
Vaclav_15-Oct-16 2:24
Vaclav_15-Oct-16 2:24 
GeneralRe: Assigning pointers from one class to another and Pin
leon de boer15-Oct-16 4:42
leon de boer15-Oct-16 4:42 
GeneralRe: Assigning pointers from one class to another and Pin
Vaclav_15-Oct-16 6:12
Vaclav_15-Oct-16 6:12 
GeneralRe: Assigning pointers from one class to another and Pin
leon de boer15-Oct-16 17:16
leon de boer15-Oct-16 17:16 
GeneralRe: Assigning pointers from one class to another and Pin
Vaclav_19-Oct-16 4:54
Vaclav_19-Oct-16 4:54 
GeneralRe: Assigning pointers from one class to another and Pin
leon de boer19-Oct-16 7:45
leon de boer19-Oct-16 7:45 
NewsHow to provide a Security to a proprietary software or presemtation. Pin
Member 1278313512-Oct-16 20:03
Member 1278313512-Oct-16 20:03 
GeneralRe: How to provide a Security to a proprietary software or presemtation. Pin
jeron113-Oct-16 4:15
jeron113-Oct-16 4:15 
GeneralRe: How to provide a Security to a proprietary software or presemtation. Pin
leon de boer13-Oct-16 8:17
leon de boer13-Oct-16 8:17 
Questionclass is missing "type" - why ? Pin
Vaclav_12-Oct-16 15:00
Vaclav_12-Oct-16 15:00 
AnswerRe: class is missing "type" - why ? PinPopular
leon de boer12-Oct-16 17:45
leon de boer12-Oct-16 17:45 
AnswerRe: class is missing "type" - why ? Pin
Graham Breach12-Oct-16 23:11
Graham Breach12-Oct-16 23:11 
QuestionObject Creation of an class? Pin
Mathan_CodeProject11-Oct-16 5:17
Mathan_CodeProject11-Oct-16 5:17 

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.