IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
HELP in C program
wb21
post 30 Mar 2010, 10:54
Post #1


Товарищ
Group Icon

Group: Members
Posts: 650
Joined: 17 June 2009
From: Philippines
Member No.: 175
ex-D' WRTHBRNGR



...have this C program I made as my college project, we've got a problem here...

CODE

# include <stdio.h>
# include <conio.h>

int choice,air1,air2;

void rus(void);
void usa(void);
void mig29(void);
void mig31(void);
void su27(void);
void su25(void);
void su24(void);
void pakfa(void);
void tu95(void);
void tu22m(void);
void tu160(void);
void f16(void);
void f15(void);
void a10(void);
void f35(void);
void f22(void);
void b1(void);
void b2(void);
void b52(void);

void main()
{
clrscr();

clrscr();

gotoxy(2,2);
cprintf("Press a hotkey");
gotoxy(2,4);
cprintf("[1] Soviet/Russian aircraft");
gotoxy(2,5);
cprintf("[2] US aircraft");
gotoxy(2,6);
cprintf("[3] Quit");
gotoxy(2,8);
cprintf("Current selection: ");
scanf("%d",&choice);


switch(choice)

{
case 1: clrscr();
rus();
break;
case 2: clrscr();
usa();
break;
case 3: gotoxy(2,10);
printf("Closing program, press any key to continue.");
break;
default: gotoxy(2,10);
printf ("Invalid key!");
break;
}
getch();
}

void rus(void)
{
int air1,choice;
clrscr();
gotoxy(2,2);
cprintf("Input the corresponding key to read the aircraft's information");
gotoxy(2,4);
cprintf("[1] MiG-29");
gotoxy(2,5);
cprintf("[2] Su-27");
gotoxy(2,6);
cprintf("[3] MiG-31");
gotoxy(2,7);
cprintf("[4] Su-24");
gotoxy(2,8);
cprintf("[5] Su-25");
gotoxy(2,9);
cprintf("[6] T-50 PAK-FA");
gotoxy(2,10);
cprintf("[7] Tu-22M");
gotoxy(2,11);
cprintf("[8] Tu-95");
gotoxy(2,12);
cprintf("[9] Tu-160");
gotoxy(2,13);
cprintf("[10] Back");
gotoxy(2,15);
cprintf("Current selection: ");
scanf("%d",&air1);

switch(choice)

{
case 1: clrscr();
mig29();
break;
case 2: clrscr();
su27();
break;
case 3: clrscr();
mig31();
break;
case 4: clrscr();
su24();
break;
case 5: clrscr();
su25();
break;
case 6: clrscr();
pakfa();
break;
case 7: clrscr();
tu22m();
break;
case 8: clrscr();
tu95();
break;
case 9: clrscr();
tu160();
break;
case 10: clrscr();
rus();
break;
default: gotoxy(2,15);
printf ("Invalid key!");
break;
}

}

void usa(void)
{
int air2,choice;
clrscr();
gotoxy(2,2);
cprintf("Input the corresponding key to read the aircraft's information");
gotoxy(2,4);
cprintf("[1] F-16");
gotoxy(2,5);
cprintf("[2] F-15");
gotoxy(2,6);
cprintf("[3] A-10");
gotoxy(2,7);
cprintf("[4] F-35");
gotoxy(2,8);
cprintf("[5] F-22");
gotoxy(2,9);
cprintf("[6] B-1B");
gotoxy(2,10);
cprintf("[7] B-2");
gotoxy(2,11);
cprintf("[8] B-52");
gotoxy(2,12);
cprintf("[9] Back");
gotoxy(2,14);
cprintf("Current selection: ");
scanf("%d",&air2);

switch(choice)

{
case 1: clrscr();
f16();
break;
case 2: clrscr();
f15();
break;
case 3: clrscr();
a10();
break;
case 4: clrscr();
f35();
break;
case 5: clrscr();
f22();
break;
case 6: clrscr();
b1();
break;
case 7: clrscr();
b2();
break;
case 8: clrscr();
b52();
break;
case 9: clrscr();
usa();
break;
default: gotoxy(2,14);
printf ("Invalid key!");
break;
}
}

void mig29(void)
{
int ret;
clrscr();
gotoxy(2,2);
cprintf("MiG-29 Fulcrum");
gotoxy(2,4);
cprintf("The Mikoyan MiG-29, NATO codename Fulcrum, is a Soviet multirole");
gotoxy(2,5);
cprintf("fighter aircraft developed in the 1970s. It became a deadly adversary");
gotoxy(2,6);
cprintf("against its US counterparts, the F-16 and the F-15. It also saw service");
gotoxy(2,7);
cprintf("with other nations, and evolved into more sophiscated variants like the MiG-35.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&ret);

switch(choice)

{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void su27(void)
{
int ret;
clrscr();
gotoxy(2,2);
cprintf("Su-27 Flanker");
gotoxy(2,4);
cprintf("The Su-27, NATO codename Flanker is a Soviet fourth-generation air");
gotoxy(2,5);
cprintf("superiority jet fighter, designed as an answer to the newer US fighters");
gotoxy(2,6);
cprintf("alongside with the MiG-29. Equipped with sophisticated avionics and armament,");
gotoxy(2,7);
cprintf("it is a formidable adversary and has other advanced versions like the Su-35.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);

switch(choice)

{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void mig31(void)
{
int ret;
clrscr();
gotoxy(2,2);
cprintf("MiG-31 Foxhound");
gotoxy(2,4);
cprintf("The MiG-31 is basically an advanced version of the MiG-25 Foxbat");
gotoxy(2,5);
cprintf("interceptor aircraft. Although cannot fly as fast or as high like its");
gotoxy(2,6);
cprintf("cousin, it has better avionics and armament systems that can pose a potential");
gotoxy(2,7);
cprintf("threat to Western air forces.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);

switch(choice)

{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void su24(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("Su-24 Fencer");
gotoxy(2,4);
cprintf("A strike aircraft, utilizing variable-geometry wings similar");
gotoxy(2,5);
cprintf("to the F-111. Replacing the older Su-7, this all-weather aircraft,");
gotoxy(2,6);
cprintf("codenamed Fencer by NATO, its saw action in conflicts involving the USSR/");
gotoxy(2,7);
cprintf("Russia. It is scheduled to be replaced by the Su-34.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);

switch(choice)

{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void su25(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("Su-25 Frogfoot");
gotoxy(2,4);
cprintf("Nicknamed Grach by Russian forces, which is bird rook in the local tongue,");
gotoxy(2,5);
cprintf("the Su-25 is a close support aircraft, well-armored and armed similar to");
gotoxy(2,6);
cprintf("the A-10. It saw action in Afghanistan in the 1980s, Iran-Iraq War by Iraqi");
gotoxy(2,7);
cprintf("pilots, and other numerous conflicts.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);

switch(choice)

{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void pakfa(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("T-50 PAK-FA");
gotoxy(2,4);
cprintf("Currently under development, the PAK-FA is Russia's next");
gotoxy(2,5);
cprintf("generation fighter aircraft, made as a successor to the MiG-29 and the");
gotoxy(2,6);
cprintf("Su-27. Resembling its American counterpart, the F-22, it is equipped with");
gotoxy(2,7);
cprintf("the latest systems, and it also has some stealth capablilities");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);

switch(choice)

{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}


void tu95(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("Tu-95 Bear");
gotoxy(2,4);
cprintf("Designed to reach American targets at long ranges, the Tu-95 is a 4-engined");
gotoxy(2,5);
cprintf("turboprop bomber.");
gotoxy(2,6);
cprintf("xxxxxxx");
gotoxy(2,7);
cprintf("xxxxxxx");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);

switch(choice)

{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void tu22m(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("Tu-22M Backfire");
gotoxy(2,4);
cprintf("Although not a derivative of the earlier Tu-22 Blinder supersonic bomber,");
gotoxy(2,5);
cprintf("the Tu-22M/26 Backfire is a swing-wing aircraft both capable of carrying missiles");
gotoxy(2,6);
cprintf("or standard bombs. In naval use, it represented a threat to NATO forces");
gotoxy(2,7);
cprintf("at sea as a result of its long-range anti-shippping strike role.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);

switch(choice)

{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void tu160(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("Tu-160 Blackjack");
gotoxy(2,4);
cprintf("A massive supersonic heavy bomber, the Tu-160, nicknamed the White Swan");
gotoxy(2,5);
cprintf("Swan because of its anti-flash white color, first saw service in the Soviet Air");
gotoxy(2,6);
cprintf("Force in the late 1980s, but only did so officially in 2005. It is allegedly");
gotoxy(2,7);
cprintf("known for dropping the most powerful non-nuclear weapon ever.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);

switch(choice)

{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void f16(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("F-16 Fighting Falcon");
gotoxy(2,4);
cprintf("The F-16 is a lightweight, multi-role fighter jet made for intense");
gotoxy(2,5);
cprintf("dogfighting and all-around versatility. First flew in the mid-1970s,");
gotoxy(2,6);
cprintf("the F-16's reasonable cost and effectiveness made it a fighter of choice");
gotoxy(2,7);
cprintf("of US and several other nations");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);

switch(choice)

{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void f15(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("F-15 Eagle");
gotoxy(2,4);
cprintf("xxxxxxx");
gotoxy(2,5);
cprintf("xxxxxxx");
gotoxy(2,6);
cprintf("xxxxxxx");
gotoxy(2,7);
cprintf("xxxxxxx");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);

switch(choice)

{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void a10(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("A-10 Thunderbolt II");
gotoxy(2,4);
cprintf("The A-10 is a rugged close support attack aircraft, the first of its");
gotoxy(2,5);
cprintf("kind in the USAF. Armed with its devastating 30mm Gatling cannon and");
gotoxy(2,6);
cprintf("a variety of munitions, the A-10 can effectively destroy tanks and other");
gotoxy(2,7);
cprintf("ground targets, like its WWII namesake, the P-47 Thunderbolt.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);

switch(choice)

{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void f35(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("F-35 Lightning II");
gotoxy(2,4);
cprintf("xxxxxxx");
gotoxy(2,5);
cprintf("xxxxxxx");
gotoxy(2,6);
cprintf("xxxxxxx");
gotoxy(2,7);
cprintf("xxxxxxx");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);

switch(choice)

{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void f22(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("F-22 Raptor");
gotoxy(2,4);
cprintf("xxxxxxx");
gotoxy(2,5);
cprintf("xxxxxxx");
gotoxy(2,6);
cprintf("xxxxxxx");
gotoxy(2,7);
cprintf("xxxxxxx");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);

switch(choice)

{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void b1(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("B-1B Lancer");
gotoxy(2,4);
cprintf("The supersonic variant in the US Air Force's bomber fleet, and after experiencing");
gotoxy(2,5);
cprintf("several setbacks on program costs and on the nature of its role, the B-1B");
gotoxy(2,6);
cprintf("Lancer, nicknamed Bone, is a swing-wing bomber that has been continually");
gotoxy(2,7);
cprintf("upgraded, armed with smart bombs and cruise missiles.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);

switch(choice)

{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void b2(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("B-2 Spirit");
gotoxy(2,4);
cprintf("The B-2 is a sophisticated stealth bomber, using its design and classified");
gotoxy(2,5);
cprintf("radar-absorbing skin that makes it virtually invisible to radar, alowing");
gotoxy(2,6);
cprintf("it to penetrate enemy airspace undetected. It is a very expensive ");
gotoxy(2,7);
cprintf("aircraft, with each one costing more than a billion dollars.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);

switch(choice)

{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void b52(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("B-52 Stratofortress");
gotoxy(2,4);
cprintf("A Cold War icon, the symbol of the West's nuclear deterrence");
gotoxy(2,5);
cprintf("at that time, and dropping a massive tonnage of bombs in Vietnam, the ");
gotoxy(2,6);
cprintf("B-52 is a versatile heavy bomber that can carry a huge load of cruise missiles");
gotoxy(2,7);
cprintf("or bombs. It is one of the longest-serving aircraft ever.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);

switch(choice)

{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}



...this is how the program should work (a pain in the ass to explain here):

1. Program will ask for selection (1 to display list of Russian planes, 2 for US planes, 3 to close the program)



2. Inputting either of the first two numbers will display the respective lists





3. Entering one of the indicated keys should display the selection's information which in this case, didn't... shady.gif



Now, HERE'S THE PROBLEM, as mentioned above, when I input a correct key, in this case "1" for "MiG-29", it displays an invalid input message as if I've typed in a wrong key instead of diplaying the info, which should be:

QUOTE
MiG-29 Fulcrum

The Mikoyan MiG-29, NATO codename Fulcrum, is a Soviet multirole
fighter aircraft developed in the 1970s. It became a deadly adversary
against its US counterparts, the F-16 and the F-15. It also saw service
with other nations, and evolved into more sophiscated variants like the MiG-35.

Press 1 to go back

Current selection:


(section of the above code)
CODE
    void mig29(void)
     {
      int ret;
      clrscr();
      gotoxy(2,2);
      cprintf("MiG-29 Fulcrum");
      gotoxy(2,4);
      cprintf("The Mikoyan MiG-29, NATO codename Fulcrum, is a Soviet multirole");
      gotoxy(2,5);
      cprintf("fighter aircraft developed in the 1970s. It became a deadly adversary");
      gotoxy(2,6);
      cprintf("against its US counterparts, the F-16 and the F-15. It also saw service");
      gotoxy(2,7);
      cprintf("with other nations, and evolved into more sophiscated variants like the MiG-35.");
      gotoxy(2,9);
      cprintf("Press 1 to go back");
      gotoxy(2,11);
      cprintf("Current selection: ");
      scanf("%d",&ret);

     switch(choice)

      {
      case 1: clrscr();
          rus();
          break;
      default: gotoxy(2,12);
           printf ("Invalid key!");
           break;
      }
      getch();
     }


I had a really rough time trying in finding out the problem, need help! smile.gif

This post has been edited by D' WRTHBRNGR: 30 Mar 2010, 11:02


--------------------

"Not in mood...go away..."
"We are going to have to act, if we want to live in a different world."

Bringing wrath to a forum near you since 2009!
Go to the top of the page
 
+Quote Post
Alias
post 30 Mar 2010, 14:07
Post #2


Cool Guy
Group Icon

Group: Legend
Posts: 1317
Joined: 7 June 2009
From: Sydney
Member No.: 46



I presume you're required to write this in C, right?

If you're not you could write it in batch with a quarter of the code.


--------------------
Go to the top of the page
 
+Quote Post
partyzanPaulZy
post 30 Mar 2010, 20:33
Post #3


"quarawr!"
Group Icon

Group: Members
Posts: 121
Joined: 14 June 2009
From: CZ (EU)
Member No.: 149
busy with uni projects and exams



Are you sure about that getch() ?

I don't use conio.h either gotoxy, but I can't find reference on that function on www.cplusplus.com.

... I'm not sure those gotoxy were neccessary anyways.


I would use different functions (dunno about that gotoxy positioning function),
but I think you have been mismatching variables: choice instead of ret, air1 or air2.

Look on switches in your code, I don't know if you have right variables there...
CODE
void mig29(void)
     {
      int ret;
      clrscr(); //you have cleared the screen so why those gotoxy functions ?
      printf("  MiG-29 Fulcrum \n");
      printf("\n");
      printf("The Mikoyan MiG-29, NATO codename Fulcrum, is a Soviet multirole\n");
      printf("fighter aircraft developed in the 1970s. It became a deadly adversary\n");
      printf("against its US counterparts, the F-16 and the F-15. It also saw service\n");
      printf("with other nations, and evolved into more sophiscated variants like the MiG-35.\n");
      printf("\n");
      printf("Press 1 to go back\n");
      printf("\n");
      printf("Current selection: ");
      ret = getchar();

     switch(ret) // haven't you mismatched vars ret and choice ?

      {
      case 1: clrscr();
          rus();
          break;
      default: gotoxy(2,12);
           printf ("Invalid key!");
           break;
      }
      //getch(); //ok, I don't know what this one does
     }


This post has been edited by partyzanPaulZy: 30 Mar 2010, 22:22


--------------------

Don't blame the others if you haven't checked your own (in)ability in first case.
Elections: It doesn't matter who wins, you always lose!

Go to the top of the page
 
+Quote Post
wb21
post 31 Mar 2010, 13:11
Post #4


Товарищ
Group Icon

Group: Members
Posts: 650
Joined: 17 June 2009
From: Philippines
Member No.: 175
ex-D' WRTHBRNGR



Here's my revised code:

CODE

# include <stdio.h>
# include <conio.h>

int choice,air1,air2;

void rus(void);
void usa(void);
void mig29(void);
void mig31(void);
void su27(void);
void su25(void);
void su24(void);
void pakfa(void);
void tu95(void);
void tu22m(void);
void tu160(void);
void f16(void);
void f15(void);
void a10(void);
void f35(void);
void f22(void);
void b1(void);
void b2(void);
void b52(void);

void main()
{
clrscr();
int GRAY,BLACK;

textbackground(GRAY);
//textcolor(BLACK);

clrscr();

gotoxy(2,2);
cprintf("Press a hotkey");
gotoxy(2,4);
cprintf("[1] Soviet/Russian aircraft");
gotoxy(2,5);
cprintf("[2] US aircraft");
gotoxy(2,6);
cprintf("[3] Quit");
gotoxy(2,8);
cprintf("Current selection: ");
scanf("%d",&choice);


switch(choice)

{
case 1: clrscr();
rus();
break;
case 2: clrscr();
usa();
break;
case 3: gotoxy(2,10);
printf("Closing program, press any key to continue.");
break;
default: gotoxy(2,10);
printf ("Invalid key!");
break;
}
getch();
}

void rus(void)
{
int air1;//choice;
clrscr();
gotoxy(2,2);
cprintf("Input the corresponding key to read the aircraft's information");
gotoxy(2,4);
cprintf("[1] MiG-29");
gotoxy(2,5);
cprintf("[2] Su-27");
gotoxy(2,6);
cprintf("[3] MiG-31");
gotoxy(2,7);
cprintf("[4] Su-24");
gotoxy(2,8);
cprintf("[5] Su-25");
gotoxy(2,9);
cprintf("[6] T-50 PAK-FA");
gotoxy(2,10);
cprintf("[7] Tu-22M");
gotoxy(2,11);
cprintf("[8] Tu-95");
gotoxy(2,12);
cprintf("[9] Tu-160");
gotoxy(2,13);
cprintf("[10] Back");
gotoxy(2,15);
cprintf("Current selection: ");
scanf("%d",&air1);

switch(choice)

{
case 1: clrscr();
mig29();
break;
case 2: clrscr();
su27();
break;
case 3: clrscr();
mig31();
break;
case 4: clrscr();
su24();
break;
case 5: clrscr();
su25();
break;
case 6: clrscr();
pakfa();
break;
case 7: clrscr();
tu22m();
break;
case 8: clrscr();
tu95();
break;
case 9: clrscr();
tu160();
break;
case 10: clrscr();
rus();
break;
default: gotoxy(2,17);
printf ("Invalid key!");
break;
}

}

void usa(void)
{
int air2,choice;
clrscr();
gotoxy(2,2);
cprintf("Input the corresponding key to read the aircraft's information");
gotoxy(2,4);
cprintf("[1] F-16");
gotoxy(2,5);
cprintf("[2] F-15");
gotoxy(2,6);
cprintf("[3] A-10");
gotoxy(2,7);
cprintf("[4] F-35");
gotoxy(2,8);
cprintf("[5] F-22");
gotoxy(2,9);
cprintf("[6] B-1B");
gotoxy(2,10);
cprintf("[7] B-2");
gotoxy(2,11);
cprintf("[8] B-52");
gotoxy(2,12);
cprintf("[9] Back");
gotoxy(2,14);
cprintf("Current selection: ");
scanf("%d",&air2);

switch(choice)

{
case 1: clrscr();
f16();
break;
case 2: clrscr();
f15();
break;
case 3: clrscr();
a10();
break;
case 4: clrscr();
f35();
break;
case 5: clrscr();
f22();
break;
case 6: clrscr();
b1();
break;
case 7: clrscr();
b2();
break;
case 8: clrscr();
b52();
break;
case 9: clrscr();
usa();
break;
default: gotoxy(2,14);
printf ("Invalid key!");
break;
}
}

void mig29(void)
{
int ret;
printf("\n");
printf(" MiG-29 Fulcrum \n");
printf("\n");
printf(" The Mikoyan MiG-29, NATO codename Fulcrum, is a Soviet multirole\n");
printf(" fighter aircraft developed in the 1970s. It became a deadly adversary\n");
printf(" against its US counterparts, the F-16 and the F-15. It also saw service\n");
printf(" with other nations, and evolved into more sophiscated variants like the MiG-35.\n");
printf("\n");
printf("\n");
ret = getchar();

switch(ret) // haven't you mismatched vars ret and choice ?

{
case 1: clrscr();
rus();
break;
default: gotoxy(2,10);
printf ("Invalid key!");
break;
}
getch(); //ok, I don't know what this one does
}


void su27(void)
{
int ret;
printf("\n");
printf(" Su-27 Flanker \n");
printf("\n");
printf(" The Su-27, NATO codename Flanker is a Soviet fourth-generation air\n");
printf(" superiority jet fighter, designed as an answer to the newer US fighters\n");
printf(" alongside with the MiG-29. Equipped with sophisticated avionics and armament,\n");
printf(" it is a formidable adversary and has other advanced versions like the Su-35.\n");
printf("\n");
printf("\n");
ret = getchar();

switch(ret)

{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void mig31(void)
{
int ret;
printf("\n");
printf(" MiG-31 Foxhound \n");
printf("\n");
printf(" The MiG-31 is basically an advanced version of the MiG-25 Foxbat\n");
printf(" interceptor aircraft. Although cannot fly as fast or as high like its\n");
printf(" cousin, it has better avionics and armament systems that can pose a potential\n");
printf(" threat to Western air forces.\n");
printf("\n");
printf("\n");
ret = getchar();

switch(ret)

{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void su24(void)
{
int ret;
printf("\n");
printf(" Su-24 Fencer \n");
printf("\n");
printf(" A strike aircraft, utilizing variable-geometry wings similar/n");
printf(" to the F-111. Replacing the older Su-7, this all-weather aircraft,/n");
printf(" codenamed Fencer by NATO, its saw action in conflicts involving the USSR//n");
printf(" Russia. It is scheduled to be replaced by the Su-34.");
printf("\n");
printf("\n");
ret = getchar();

switch(ret)

{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
//getch();
}

void su25(void)
{
int ret;
printf("\n");
printf(" Su-25 Frogfoot \n");
printf("\n");
printf(" Nicknamed Grach by Russian forces, which is bird rook in the local tongue,\n");
printf(" the Su-25 is a close support aircraft, well-armored and armed similar to\n");
printf(" the A-10. It saw action in Afghanistan in the 1980s, Iran-Iraq War by Iraqi\n");
printf(" pilots, and other numerous conflicts.");
printf("\n");
printf("\n");
ret = getchar();

switch(ret)

{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void pakfa(void)
{
int ret;
printf("\n");
printf(" T-50 PAK-FA\n");
printf("\n");
printf(" Currently under development, the PAK-FA is Russia's next\n");
printf(" generation fighter aircraft, made as a successor to the MiG-29 and the\n");
printf(" Su-27. Resembling its American counterpart, the F-22, it is equipped with\n");
printf(" the latest systems, and it also has some stealth capablilities\n");
printf("\n");
printf("\n");
ret = getchar();

switch(ret)

{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}


void tu95(void)
{
int ret;
printf("\n");
printf(" Tu-95 Bear\n");
printf("\n");
printf(" Designed to reach American targets at long ranges, the Tu-95 is a 4-engined\n");
printf(" turboprop bomber.\n");
printf(" xxxxxxx\n");
printf(" xxxxxxx\n");
printf("\n");
printf("\n");
ret = getchar();

switch(ret)

{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void tu22m(void)
{
int ret;
printf("\n");
printf(" Tu-22M Backfire\n");
printf("\n");
printf(" Although not a derivative of the earlier Tu-22 Blinder supersonic bomber,\n");
printf(" the Tu-22M/26 Backfire is a swing-wing aircraft both capable of carrying missiles\n");
printf(" or standard bombs. In naval use, it represented a threat to NATO forces\n");
printf(" at sea as a result of its long-range anti-shippping strike role.\n");
printf("\n");
printf("\n");
ret = getchar();

switch(ret)

{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void tu160(void)
{
int ret;
printf("\n");
printf(" Tu-160 Blackjack");
printf("\n");
printf(" A massive supersonic heavy bomber, the Tu-160, nicknamed the White Swan\n");
printf(" Swan because of its anti-flash white color, first saw service in the Soviet Air\n");
printf(" Force in the late 1980s, but only did so officially in 2005. It is allegedly\n");
printf(" known for dropping the most powerful non-nuclear weapon ever.\n");
printf("\n");
printf("\n");
ret = getchar();

switch(ret)

{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void f16(void)
{
int ret1;
printf("\n");
printf("F-16 Fighting Falcon \n");
printf("\n");
printf("The F-16 is a lightweight, multi-role fighter jet made for intense\n");
printf("dogfighting and all-around versatility. First flew in the mid-1970s,\n");
printf("the F-16's reasonable cost and effectiveness made it a fighter of choice\n");
printf("of US and several other nations\n");
printf("\n");
printf("\n");
ret1 = getchar();

switch(ret1)

{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void f15(void)
{
int ret1;
printf("\n");
cprintf("F-15 Eagle\n");
printf("\n");
cprintf("xxxxxxx \n");
cprintf("xxxxxxx \n");
cprintf("xxxxxxx \n");
cprintf("xxxxxxx \n");
printf("\n");
printf("\n");
ret1 = getchar();

switch(ret1)

{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void a10(void)
{
int ret1;
printf("\n");
cprintf("A-10 Thunderbolt II \n");
printf("\n");
cprintf("The A-10 is a rugged close support attack aircraft, the first of its\n");
cprintf("kind in the USAF. Armed with its devastating 30mm Gatling cannon and\n");
cprintf("a variety of munitions, the A-10 can effectively destroy tanks and other\n");
cprintf("ground targets, like its WWII namesake, the P-47 Thunderbolt.\n");
printf("\n");
printf("\n");
ret1 = getchar();

switch(ret1)

{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void f35(void)
{
int ret1;
printf("\n");
cprintf("F-35 Lightning II\n");
printf("\n");
cprintf("xxxxxxx\n");
cprintf("xxxxxxx\n");
cprintf("xxxxxxx\n");
cprintf("xxxxxxx\n");
printf("\n");
printf("\n");
ret1 = getchar();

switch(ret1)

{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void f22(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("F-22 Raptor");
gotoxy(2,4);
cprintf("xxxxxxx");
gotoxy(2,5);
cprintf("xxxxxxx");
gotoxy(2,6);
cprintf("xxxxxxx");
gotoxy(2,7);
cprintf("xxxxxxx");
printf("\n");
printf("\n");
ret1 = getchar();

switch(ret1)

{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void b1(void)
{
int ret1;
printf("\n");
cprintf("B-1B Lancer");
printf("\n");
cprintf("The supersonic variant in the US Air Force's bomber fleet, and after experiencing\n");
cprintf("several setbacks on program costs and on the nature of its role, the B-1B\n");
cprintf("Lancer, nicknamed Bone, is a swing-wing bomber that has been continually\n");
cprintf("upgraded, armed with smart bombs and cruise missiles.\n");
printf("\n");
printf("\n");
ret1 = getchar();

switch(ret1)

{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void b2(void)
{
int ret1;
printf("\n");
cprintf("B-2 Spirit \n");
printf("\n");
cprintf("The B-2 is a sophisticated stealth bomber, using its design and classified\n");
cprintf("radar-absorbing skin that makes it virtually invisible to radar, allowing\n");
cprintf("it to penetrate enemy airspace undetected. It is a very expensive\n");
cprintf("aircraft, with each one costing more than a billion dollars.\n");
printf("\n");
printf("\n");
ret1 = getchar();

switch(ret1)

{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}

void b52(void)
{
int ret1;
printf("\n");
cprintf("B-52 Stratofortress \n");
printf("\n");
cprintf("A Cold War icon, the symbol of the West's nuclear deterrence \n");
cprintf("at that time, and dropping a massive tonnage of bombs in Vietnam, the\n");
cprintf("B-52 is a versatile heavy bomber that can carry a huge load of cruise missiles\n");
cprintf("or bombs. It is one of the longest-serving aircraft ever.\n");
printf("\n");
printf("\n");
ret1 = getchar();

switch(ret1)

{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}



--------------------

"Not in mood...go away..."
"We are going to have to act, if we want to live in a different world."

Bringing wrath to a forum near you since 2009!
Go to the top of the page
 
+Quote Post
beefJeRKy
post 1 Apr 2010, 17:56
Post #5


Formerly Scopejim
Group Icon

Group: Members
Posts: 369
Joined: 7 June 2009
From: Land of the Cedar
Member No.: 38
Electronics Engineer



This is why one uses object oriented languages. Sorry I can't help you though. I know C++ and Java.
Go to the top of the page
 
+Quote Post
Deathwarror
post 1 Apr 2010, 22:42
Post #6



Group Icon

Group: Members
Posts: 5
Joined: 3 August 2009
From: colorado
Member No.: 316



CODE

cprintf("Current selection: ");
scanf("%d",&air1);

switch(choice)


This is located in the rus() function. The error is caused because you read in a choice into the variable but you are, from what i can tell, using a different variable that was not given any value. that would give you the first error. I don't know if you have any other errors because I don't have any way of test running the code.
Go to the top of the page
 
+Quote Post
partyzanPaulZy
post 1 Apr 2010, 23:43
Post #7


"quarawr!"
Group Icon

Group: Members
Posts: 121
Joined: 14 June 2009
From: CZ (EU)
Member No.: 149
busy with uni projects and exams



Actually there are rus() and usa() functions with this bug, fix them and it should work properly. wink.gif

now I am gonna back to my school project around primitive server-client file transfer...

This post has been edited by partyzanPaulZy: 2 Apr 2010, 0:05


--------------------

Don't blame the others if you haven't checked your own (in)ability in first case.
Elections: It doesn't matter who wins, you always lose!

Go to the top of the page
 
+Quote Post
wb21
post 3 Apr 2010, 12:52
Post #8


Товарищ
Group Icon

Group: Members
Posts: 650
Joined: 17 June 2009
From: Philippines
Member No.: 175
ex-D' WRTHBRNGR



QUOTE (Deathwarror @ 2 Apr 2010, 2:42) *
CODE

cprintf("Current selection: ");
scanf("%d",&air1);

switch(choice)


This is located in the rus() function. The error is caused because you read in a choice into the variable but you are, from what i can tell, using a different variable that was not given any value. that would give you the first error.


OK, I'll check this one. wink.gif

QUOTE (Deathwarror @ 2 Apr 2010, 2:42) *
I don't know if you have any other errors because I don't have any way of test running the code.


So far that was the only errors I encounter, i.e. properly displaying the corresponding pages as I've explained on my first post.


--------------------

"Not in mood...go away..."
"We are going to have to act, if we want to live in a different world."

Bringing wrath to a forum near you since 2009!
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 27 April 2024 - 0:09