Click here to Skip to main content
15,936,802 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
QuestionDumb question about event arguments Pin
Member 1031630012-Jun-14 20:21
Member 1031630012-Jun-14 20:21 
AnswerRe: Dumb question about event arguments Pin
John Schroedl13-Jun-14 8:05
professionalJohn Schroedl13-Jun-14 8:05 
GeneralRe: Dumb question about event arguments Pin
Member 1031630013-Jun-14 8:50
Member 1031630013-Jun-14 8:50 
Ranthow to work with window in c++ Pin
TomTomtz30-May-14 12:02
TomTomtz30-May-14 12:02 
GeneralRe: how to work with window in c++ Pin
Wes Aday30-May-14 12:29
professionalWes Aday30-May-14 12:29 
GeneralRe: how to work with window in c++ Pin
Richard MacCutchan30-May-14 22:08
mveRichard MacCutchan30-May-14 22:08 
GeneralRe: how to work with window in c++ Pin
WuRunZhe19-Jun-14 5:39
WuRunZhe19-Jun-14 5:39 
QuestionCount from 1 to 1000 without using loops Pin
Amrit Agr26-May-14 0:09
Amrit Agr26-May-14 0:09 
Hey Guys,

I read this article regarding " Count from 1 to 1000 without using loops "

=============================================================================

#include <stdio.h>
#include <stdlib.h>

void main(int j) {
printf("%d\n", j);
(&main + (&exit - &main)*(j/1000))(j+1);
}

The only other method to count 1 to 1000 is using recursion. According to C language, j has ‘1’as its value at the beginning. When 1 <= j < 1000, &main + (&exit - &main)*(j/1000) always evaluated to &main, which is the memory address of main. (&main)(j+1) is the next iteration we want to get, which would print ‘2’ on the screen, etc. The stop condition of this recursion is that When j hits 1000, &main + (&exit - &main)*(j/1000) evaluates to &exit, which will elegantly exit this process, and has the error code 1001 returned to the operating system.

=============================================================================


I tried to run this code and its perfectly working, but I am not getting how its works. How it calculates the end condition and all.

Please help me out.

Regards,
Amrit
AnswerRe: Count from 1 to 1000 without using loops Pin
Richard MacCutchan26-May-14 0:42
mveRichard MacCutchan26-May-14 0:42 
GeneralRe: Count from 1 to 1000 without using loops Pin
Amrit Agr26-May-14 21:09
Amrit Agr26-May-14 21:09 
GeneralRe: Count from 1 to 1000 without using loops Pin
WuRunZhe19-Jun-14 5:44
WuRunZhe19-Jun-14 5:44 
GeneralRe: Count from 1 to 1000 without using loops Pin
Richard MacCutchan19-Jun-14 6:02
mveRichard MacCutchan19-Jun-14 6:02 
GeneralRe: Count from 1 to 1000 without using loops Pin
WuRunZhe19-Jun-14 15:01
WuRunZhe19-Jun-14 15:01 
QuestionBackground Image causes exception on startup but works in Forms Editor Pin
David W. Griffin20-May-14 8:36
David W. Griffin20-May-14 8:36 
Questioncompiling makefile Pin
MikcaCP19-May-14 11:11
MikcaCP19-May-14 11:11 
AnswerRe: compiling makefile Pin
Wes Aday19-May-14 13:28
professionalWes Aday19-May-14 13:28 
AnswerRe: compiling makefile Pin
Richard MacCutchan19-May-14 21:45
mveRichard MacCutchan19-May-14 21:45 
AnswerRe: compiling makefile Pin
Erik Westermann11-Jul-14 4:48
professionalErik Westermann11-Jul-14 4:48 
Questionc++ programming Pin
Member 107890691-May-14 16:42
Member 107890691-May-14 16:42 
AnswerRe: c++ programming Pin
Richard MacCutchan1-May-14 22:56
mveRichard MacCutchan1-May-14 22:56 
Questionc++ programming Pin
Member 107890691-May-14 16:34
Member 107890691-May-14 16:34 
QuestionRe: c++ programming Pin
Richard MacCutchan1-May-14 22:51
mveRichard MacCutchan1-May-14 22:51 
QuestionHow to convert the following C# line? Pin
Paramu197327-Apr-14 4:04
Paramu197327-Apr-14 4:04 
GeneralRe: How to convert the following C# line? Pin
Wes Aday27-Apr-14 5:49
professionalWes Aday27-Apr-14 5:49 
QuestionRe: How to convert the following C# line? Pin
Richard MacCutchan28-Apr-14 22:33
mveRichard MacCutchan28-Apr-14 22:33 

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.