Thread: help!!!

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    3

    help!!!

    My program needs help Please some one degug it make it better
    anything

    #ifndef game1_H
    #define game1_H

    char class1[3]; // Used in Class Selection
    char name[10]; // Used in the Name selection and storage
    char answr;// used in yes or no questions.
    int armor,hp,attack;



    void charsel(); // Function prototype for Character select.
    void begin();
    void namesel();
    void game();
    void adv1();


    #endif

    FILE * pFile = NULL;
    long n = 0;
    pFile = fopen ("myfile.txt","wt"); //write in text mode
    if (pFile==NULL)
    {
    printf("Error with myfile.txt");
    }
    else
    {
    fprintf(pFile, "%d %d %d",var1,var2,var3); //this will write 3 vars to the text file
    }
    fclose (pFile);
    }
    return 0;
    --------------------------------------------------------------------------------







    #include <stdio.h>
    #include <stdlib.h>
    #include <process.h>
    #include <string.h>
    #include <math.h>
    #include <time.h>
    #include "vars.h"
    #include <iostream.h>
    #include <conio.h>


    void clearscreen()
    {
    int i;
    i=0;
    for (i=1;i<=15;++i)
    {
    printf("\n");
    }
    }
    void main()
    {
    namesel();
    charsel();
    begin();
    game();
    clearscreen();
    adv1();
    clearscreen();
    }


    void charsel()
    {
    /* Choose Character*/
    printf("Enter your character class, Barbarian, Archer, Mage, or Assassin\n");
    scanf("%s",&class1[3]);
    class1[3]=toupper(class1[3]);

    switch (class1[3])
    {
    case 'B':
    {
    printf ("Barbarian, your stats are: Armor 8, Hit Points 8, and Attack d12.\n");
    armor = 8;
    hp = 8;
    attack = 12;
    break;
    }
    case 'A':
    {
    printf ("Archer, your stats are: Armor 6, Hit Points 6, Attack d10(long range), and d8 (short sword).\n");
    armor = 6;
    hp = 6;
    attack = 10;
    break;
    }
    case 'M':
    {

    printf ("Mage, your stats are: Armor 4, Hit Points 4, and Attack d8.\n");
    armor = 4;
    hp = 4;
    attack = 8;
    break;
    }
    case 'S':
    {
    printf ("Assassin, your stats are: Armor 6 and Hit Points 6.\n");
    armor = 6;
    hp = 6;
    attack = 8;
    break;
    }
    default:
    {
    system("cls");
    printf("\n for Barbarian type B ");
    printf("\n for Archer type A ");
    printf("\n for Mage type M ");
    printf("\n for Assassin type S \n");
    charsel();
    break;
    }
    }
    _flushall();
    }

    void begin()
    {
    /* Begin Adventure */

    printf ("It is time to begin your adventure...\n");

    system("pause");
    system("clr");
    }

    void namesel()
    {
    printf("The air is cold around you. You wonder if anyone is still alive. You see that you father was taken under arrest by the king of Underwood. You go to see him. He tells you that you must be worthy to bail your father out of jail, that you must become a hero before you get your father back. 'Go now, but beware if you do not do what I tell you then your clan will surely die!' WELCOME TO DARKSHYOUR!\n");
    printf ("what is your name?\n");
    printf ("(must be less than 10 characters, and contain no spaces.)\n");
    scanf("%s", name);
    printf("\n %s of Darkshyour.\n",name );
    printf ("\nWell then, %s of Darkshyour, be on your way, but be warned of the monsters ahead!\n",name);
    }

    void game()
    {

    }

    void adv1()
    {
    printf("King Newfrown needs your help.\n");

    printf ("He says, 'I need you to retrive my Glorious Sceptre of Righteousness; bring it back and recieve a reward.' Do you accept?\n");
    printf ("(Enter y or n.)\n");

    scanf("%c",&answr);

    answr = toupper(answr);
    switch (answr)
    {
    case 'Y': break;
    printf("Fine then but be on your way beware of all the monsters a head");

    case 'N':
    {
    system("clr");
    printf ("Oh well. GUARDS! KILL THE TRAITOR! You had your chance. Bye bye.\n");
    exit(1);
    }

    default:
    {
    system("clr");
    printf ("That wasn't a yes, so I'm assuming it was a no. GUARDS, KILL THEM!\n");
    exit(1);
    }
    }

    system("clr");
    printf("You enter the room");
    }

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    And the vague problem of the day award goes to...

    What's the problem? OS? Compiler? Error messages?

    Right away - If you're using Windows, system(clr) isn't going to do anything you want it to, secondly, main returns an int...

Popular pages Recent additions subscribe to a feed