On Thu, Mar 11, 2010 at 3:40 PM, sruthy_inuyasha
<[email protected]> wrote:
>
> #include<stdlib.h>
> #include<iostream.h>

Why are you using both C and (very old) C++ headers. Decide which
language you're using and stick to it. The only time you should be
mixing the two is with legacy applications written in C and you're
moving it to C++.

> void main()

main returns int. Not void, float or struct foo.

> {
> randomize();

No such function in Standard C (or C++), and you don't seem to define
it. Look up srand().

> char Area[][10]={"North","South","East","West"};

char* Area[] = {"North","South","East","West"};

> int ToGo;
> for(int i=0; i<3; i++)
> {
> ToGo = random(2)+1;

No such function in Standard C (or C++), and you don't seem to define
it. Look up rand(), and read <http://c-faq.com/lib/randrange.html>

> cout<<Area[ToGo]<<":";
> }
>
> Outputs are
>
> North:South:East
> South:East:South
> South:East:East
>
> Can you tell me how North:South:East is possible?? I tried and I have no
> idea hw that output is possible. If it is possible how do I get it ( I
> meant the procedure)?

Ignoring the fact that you fail to flush cout, those lines, if
copy/pasted, seem to be missing : on the ends of the lines.

Why you're getting seemingly impossible results are probably because
your program is invoking undefined behaviour.

-- 
PJH

http://shabbleland.myminicity.com/tra
http://www.chavgangs.com/register.php?referer=9375

Reply via email to