ok ok ready for another big step.
ok heres what i got you have 4 directions for the index if you try to type in something higher than whats inside the array my message will pop up and the program will end,
Q:what do i type to get the program to start over again from the top ?
Code:
#include <stdio.h>
#include <stdlib.h>
# define direct_max 3
int main(void)
{
int room0[direct_max]={1,2,-1,-1};
int i;
printf("number please, later it will be direction:");
scanf("%i",&i);
if (i>direct_max)
{
printf("you have to type n,s,e,w for you directions nothing else will work.");
return 1; /// i have it end here if you dont type 0,1,2,3.
}
printf("print the god dam numb. %i",room0[i]);
///it prints the number corresponding the array.
return 0;
}
i hate you, i hate all of you.
this is as close to "not code" that i can get i think, i dont know, your program dosent even look like it works. i was show to make a program that works then add on from there with more programs that work. so i chucked everything i learned out the window and made a program that dose not work.
there are 4 rooms you are in room 0 you have to make the decision to go to rooms 1 or 2 and thats it, i dont know how to make any thing continue and\or asking again.
i dont know what i am doing any more?so confused?
Code:
#include <stdio.h>
#include <stdlib.h>
# define map_max 4
int main(void)
{
int map[3][map_max]={
{1, 2,-1,-1},
{2, 0,-1,-1},
{0, 1,-1, 3},
{-1,-1,2,-1}
};
printf("you are in room %i",0)
directions.c /// this is the program i have been working on all through out
this post, i did some small changes like implementing the
matrix and changed the words, but it still dose the same
thing, so its still have the same problems.
if(i==-1){
printf("up yours")
else{
printf("you are in room %i",i)
return 0;
}
dont think me as rude i am not ignoring you advise i just incapable to use it.
heres what i got, i am having a rough time trying to figure out how to make a multidimensional array function. so could you tell me how i am screwing up or give me an example of a correct one. the finction next_room is what it is called and what i want iit to do is spit out the matrix number.
Code:
#include <stdio.h>
#include <stdlib.h>
# define max_room 4
# define max_go 4
void script (int room_num){
if (room_num==0){
printf("room0");
}
if (room_num==1){
printf("room1");
}
if (room_num==2){
printf("room2");
}
if (room_num==3){
printf("room3");
}
if(room_num==-1){
printf("ass");
}
}
int next_room (int room, int direction,int map[][]){
int map[room][direction]={
{1, 2,-1,-1},
{2, 0,-1,-1},
{0, 1,-1, 3},
{-1,-1,2,-1}
};
return map[room][direction];
}
int conversion (char letter){
if(letter=='n')
{
letter=0;
}
else if(letter=='s')
{
letter=1;
}
else if(letter=='e')
{
letter=2;
}
else if(letter=='w')
{
letter=3;
}
else
{
printf("No!, After wandering for hours you figure out %c is not a actual direction. You've walked in to the slabbering fangs of a lurking Grue\n", letter);
return 0;
}
return letter;
}
int main (void)
{
char letter;
printf("direction:");
scanf("%c",&letter);
printf("%i",);
script (nextroom(room,conversion(letter)));
return 0;
}
confusing is my middle name
I cant figure this out, i am not quit sure i understand what your saying about my next_room function, maby an example would help, i am a very visual learner, oh and yes the map is unchanging.
i tryed some diffrent ways but none seem to work i must going at this in the wrong way.
Code:
int next_room (int room, int direction){
int map[room][direction]={
{1, 2,-1,-1},
{2, 0,-1,-1},
{0, 1,-1, 3},
{-1,-1,2,-1}
};
return map[room][direction];
}
or
Code:
int next_room (int map[][]){
int map[room][direction]={
{1, 2,-1,-1},
{2, 0,-1,-1},
{0, 1,-1, 3},
{-1,-1,2,-1}
};
return map[room][direction];
}
or
Code:
# define max_room 4
# define max_die 4
.
.
.
int next_room (map[room][directions]){
int map[max_room][max_die]={
{1, 2,-1,-1},
{2, 0,-1,-1},
{0, 1,-1, 3},
{-1,-1,2,-1}
};
return map[room][direction];
}
edit:
or ///this one has one error, parse error "=".
Code:
# define max_room 4
# define max_go 4
int next_room (int a, int b, int map[max_room][max_go]={
{1, 2,-1,-1},
{2, 0,-1,-1},
{0, 1,-1, 3},
{-1,-1,2,-1}
}){
}
or have i forgotten my brains today.