Yes for the record, I have been programming since I was 12. Started out with BASIC on the Vic-20 using PEEK and POKE commands as well as other various BASIC commands. I have worked my way up over the years studying various languages over the past 3 decades.
And you three are not being helpful at all. I'm done with this thread. If SIK wants to IM me about the results I welcome it. Maybe he can help me understand why this is not working for the OP and myself like it does for you three Trolls here.
@WinwordExonar
I think Peter87 pointed out why yours and the OPs goes into an infinit loop - I just merely pointed out with a very basic example the differences between using a star and not.
Unfortunately my hardware allocated the memory indicated from your example - probably due to OS creating virtual memory through swap file - so I'm not going to test this until my swap file fills my harddrive.
What was your result when you tested with count = 3?
My interest in asking this is to esteshblish if you see the same results I am seing with the exact same code.
ok did it go to the infinite loop for everyone else who tried?? the input should be really big enough like 232 or even more......mine enters the infinite loop in 'codeblocks 10.05' with mingw gcc, but works fine in same ide with cygwin gcc for any big input....i'm using win7(x64).....in cygwin gcc the value for i is set to 231-1 if u input any number bigger than that (i used cout to see the values of i) probably that's why using cygwin gcc i can enter any large value i want, but that value doesn't get in 2 use....so i can't err even if i want 2..... :(
whatever changing from if (p == 0) to if (*p == 0) (according to WinwordExonar) using mingw gcc the value of 231-1(and for some more valuess lower than it) crashes the prog....but works fine for values larger than that....... :|
and thanks Peter87 for ur code.....i didn't know this about cin b4....i tried ur code & it works kool....i can't give just any input, i have a limit now(int_max)......anyways, what does cin return if it succeeds or fails? thanks in advance.
cin >> i; fails if the number entered is too large [...] if it fails, i will not be changed. i was never initialized, so it still has the same indeterminate value as before.
kOdL3R wrote:
in cygwin gcc the value for i is set to 231-1 if u input any number bigger than that
This is the difference between C++98/C++03 (i is not modified) and C++11 (i is set to INT_MAX). In either case, cin's failbit is set, so everything that was said about checking cin applies.
This is the difference between C++98/C++03 (i is not modified) and C++11 (i is set to INT_MAX). In either case, cin's failbit is set, so everything that was said about checking cin applies.
thanx Cubbi for pointing this out....i didn't know this......so this means cygwin gcc is based on C++11 and more updated??
@WinwordExonar :
dude i think after declaring int *p , p becomes a pointer and should return the memory address it's pointing to which would be a hex value(just guessing, they look like hex...) & not an integer or even the value located @ the memory address of which it is a pointer......don't take it otherwise, i'm just a beginner & am not trying 2 judge u or anyone but trying 2 clear my own probs...& i expect help 4m everyone....plz have a look @ the following code :