[ Login | Register ]

The Shining Source

« previous next »
Pages: [1] Print
Why don't this compile?   (Read 13584 times)
Old Post November 25, 2004, 05:17:57 pm
#1
Shining Light *

Posts: 207

Logged
Why don't this compile?
This isn't anything major.  I just figured I'd see if I could get something to compile in c++, since I've never been able to before.  It's just a simple scrolling menu, and I can't find anything wrong with my code.  I'm using dev-c++

Code:

#include <stdio.h>
//#include <stdlib.h>
//#include <iostream.h>
#include <string.h>
#include <conio.h>

struct options
{
char newgame[]="NEW GAME";
char loadgame[]="LOAD GAME";
char options1[]="OPTIONS";
}
int option_loc[3];
option_loc[0]=&options.newgame;
option_loc[1]=&options.loadgame;
option_loc[2]=&options.options1;

function scrollmenu();
int choice=1;
int input=0;
int takein;
{
while (input!=1)
{
cls;
cout<<*option_loc[choice-1]<<*option_loc[choice]<<*option_loc[choice+1];
getch(takein);
if (takein==6) {choice+=1;}
if (choice==3) {choice=0;}
if (takein==4) {choice-=1;}
if (choice==-1) {choice=2;}
}
int main();
{
scrollmenu();
return 0;
}


The two commented out libraries are as such because the compiler was complaining about them being antiquated.  What is wrong with this code?

i>never knows best


Old Post November 26, 2004, 08:42:41 am
#2
Shining Something *

Posts: 143

Logged
Why don't this compile?
Don't you have to declare your function "scrollmenu" in the upper portion of the code before actually programming it?

It's just a guess...

hining Odyssey under devlopment: http://mapage.noos.fr/zylokh


Old Post November 26, 2004, 08:44:00 pm
#3
Shining Light *

Posts: 207

Logged
Why don't this compile?
No.  You only have to do that if you're calling the function in things coded higher up than it.  In this case I am not and it is unneccessary.

i>never knows best


Old Post November 27, 2004, 12:52:00 am
#4
Ty
Administrator
Shining Sideburns *

Posts: 836

Logged
Why don't this compile?
A lot of braces missing, and it looks like a cross between Pascal code and C++ code. Haven't looked over it completely but a lot of things look wrong to me.


New Post December 01, 2004, 12:10:00 pm
#5
bEn
Shining Light *

Posts: 224

Logged
Why don't this compile?
Code:

function scrollmenu();
int choice=1;
int input=0;
int takein;
{
   while (input!=1)
   {
      cls;
      cout<<*option_loc[choice-1]<<*option_loc[choice]<<*option_loc[choice+1];
      getch(takein);
      if (takein==6) {choice+=1;}
      if (choice==3) {choice=0;}
      if (takein==4) {choice-=1;}
      if (choice==-1) {choice=2;}
   }



What is this? A function that is nothing more than a stub, and commands that are lost in the middle of nowhere. I mean the while loop - to which function does it belong?
Another thing is that it looks more like C than C++ but that's more a matter of taste than problems ;-)

t's not like I really care


Pages: [1] Print 
« previous next »
Jump to:  

Powered by SMF 1.1.21 | SMF © 2013, Simple Machines