A begginer writing a text based dungeon game.
This will be the first of many questions to come
This is an assinment so dont give me code i won't understand becouse i wont use it, even if you give me code i understand i still won't use it but i will learn from it.
in this code i am trying to get a specific number to print out when the user types n, e, s, or w.
for example: n would be 1, and e would be -1.
all it dose is give me some strange error called signal 10 (sigbus) then it pulls up a debugger window sorry if this sounds to common it's never happend to me before.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int room0[4]={1,2,-1,-1};
char i;
char n=0;
char s=1;
char e=2;
char w=4;
printf("number...err letter:");
scanf("%c\n",i);
printf("print the god dam numb. %i",room0[i]);
return 0;
}
please before reading whats below, can you answer the above question first even if it will not help me with the game, it's how i learn things,i am very new at this got no experience at all.
as for the text base game this is how its planned, so far i am planning to have 4 rooms and am writing the code in 4 parts, 1 for each room it sounds tedius but i just want to get from 1 room to the other for right now. the rooms have numbers 0-3, you get from each room by pressing n,s,e,w. if you try to go the wrong way its a -1. i am thinking the use of arrays, if else statements and goto statment. if there is more things i should or not use don't be shy speek up.
and now for my stupid questions
1)can you get an array of letters to equal an array of numbers.
i guess that will be it for now i will post more questions as soon as they become more prevalent to the main question.
lastly you are all probably wondering what text i am using, well i am using Programming in C third edition Stephen G. Kochan Developer's Library