function call errors, HELP!
2 posters
RUSES :: Part 1 :: Programming :: Coursework
Page 1 of 1
function call errors, HELP!
Hi guys. I keep getting an error in my function call for:
int movechecky ( x , y, dir, maze1[19][23]);
it wants me to put brackets around the x. i think it doesn't want to accept all four function parameters.
i put my functions in their own header file, and the prototypes in another header (with a #pragma once), then include both these header files in my main.cpp
the prototype is:
int movechecky (int x, int &y, int dir, int maze1[19][23]);
all the relevant code is right here. it's all lumped into one, so needs to be separated into header & cpp files before it can be compiled. i put comments in where each file starts.
http://pastie.org/private/avz8kptqudwxzzqhzzzdw
thanks =)
int movechecky ( x , y, dir, maze1[19][23]);
it wants me to put brackets around the x. i think it doesn't want to accept all four function parameters.
i put my functions in their own header file, and the prototypes in another header (with a #pragma once), then include both these header files in my main.cpp
the prototype is:
int movechecky (int x, int &y, int dir, int maze1[19][23]);
all the relevant code is right here. it's all lumped into one, so needs to be separated into header & cpp files before it can be compiled. i put comments in where each file starts.
http://pastie.org/private/avz8kptqudwxzzqhzzzdw
thanks =)
VicVic- Posts : 17
Join date : 2012-02-28
Re: function call errors, HELP!
Change int movechecky ( x , y, dir, maze1[19][23]);
to
int movechecky ( int , int, int, int[][]);
failing that:
int movechecky ( int x, int y, int dir, int maze1[19][23]);
You are defining the function parameters by variable names instead of by their types
*goes to actually read code just in case this doesn't work*
to
int movechecky ( int , int, int, int[][]);
failing that:
int movechecky ( int x, int y, int dir, int maze1[19][23]);
You are defining the function parameters by variable names instead of by their types
*goes to actually read code just in case this doesn't work*
Alex- Posts : 67
Join date : 2012-02-23
Location : Come at me bro
Re: function call errors, HELP!
Should work, one problem is there's no function for movecheckx()
- Code:
//movecheck.h :
#pragma once
//this needs to be in movecheck
int movechecky (int x, int &y, int dir, int maze1[19][23]);
int movecheckx (int &x, int y, int dir, int maze1[19][23]);
int movechecky (int x, int &y, int dir, int maze1[19][23])
{
switch (dir)
{
case 'n':
{
if (maze1[x][y+1] = 0)
{
break;
return -1;
}
else
if (maze1[x][y+1] = 1)
{
y++;
}
}
break;
case 's':
{
if (maze1[x][y-1] = 0)
{
break;
return -1;
}
else
if (maze1[x][y-1] = 1)
{
y--;
}
}
break;
default :
break;
}
return y;
}
Alex- Posts : 67
Join date : 2012-02-23
Location : Come at me bro
Re: function call errors, HELP!
haven't gotten around to movecheckx just yet. was going to just copy paste the movechecky and edit it once i got movechecky working.
Thanks very much, I'll give it a try =)
Thanks very much, I'll give it a try =)
VicVic- Posts : 17
Join date : 2012-02-28
Re: function call errors, HELP!
And you need to #include movecheck.h - about to compile and test it in a sec just to see though
Alex- Posts : 67
Join date : 2012-02-23
Location : Come at me bro
Re: function call errors, HELP!
Haha oops! I deleted it out earlier to copy some other stuff to someone else and never put it back...
VicVic- Posts : 17
Join date : 2012-02-28
Re: function call errors, HELP!
Okay solved
movecheck.h (you need to create movecheckx()
main.cpp
movecheck.h (you need to create movecheckx()
- Code:
int movechecky (int x, int &y, int dir, int maze1[19][23]);
int movecheckx (int &x, int y, int dir, int maze1[19][23]);
int movechecky (int x, int &y, int dir, int maze1[19][23])
{
switch (dir)
{
case 'n':
{
if (maze1[x][y+1] = 0)
{
break;
return -1;
}
else
if (maze1[x][y+1] = 1)
{
y++;
}
}
break;
case 's':
{
if (maze1[x][y-1] = 0)
{
break;
return -1;
}
else
if (maze1[x][y-1] = 1)
{
y--;
}
}
break;
default :
break;
}
return y;
}
int movecheckx (int &x, int y, int dir, int maze1[19][23])
{
return 0;
}
main.cpp
- Code:
#include <iostream>
#include <string>
#include <limits>
#include "movecheck.h"
using namespace std;
//note to self: array[y][x] - gives 'y' arrays (rows) with 'x' elements (columns) in each.
int main ()
{
int maze1[19][23] = {
{0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0},
{0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,1,0,1,0},
{0,1,1,1,0,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,0},
{0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1,0},
{0,1,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,0},
{0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,1,0},
{0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,1,1,1,0,1,0,1,0},
{0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,1,0,1,0,1,0,1,0},
{0,1,1,1,0,1,0,1,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0},
{0,0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0},
{0,1,1,1,0,1,1,1,0,1,0,1,0,1,1,1,0,1,0,1,0,0,0},
{0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,1,1,0},
{0,1,1,1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,0,1,0,1,0},
{0,0,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0,1,0,1,0,1,0},
{0,1,1,1,0,1,0,1,0,1,1,1,0,1,1,1,0,1,0,1,0,1,0},
{0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,1,0,1,0,0,0},
{0,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,1,1,1,1,1,3},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
};
cout <<
"###############################################################################" <<endl <<
"# #" <<endl <<
"# Written by #" <<endl <<
"# Victoria Lawson #" <<endl <<
"# YG000976 #" <<endl <<
"# @ Univeristy of Reading #" <<endl <<
"# #" <<endl <<
"# WELCOME TO MY MAZE #" <<endl <<
"# #" <<endl <<
"###############################################################################" <<endl <<
"Press enter to start";
cin.ignore(numeric_limits <streamsize> ::max(), '\n' );
fflush(stdin);
cout << string(50, '\n');
int x=1, y=0;
cout << "->You find yourself at the start of what appears to be a maze." << endl <<
"There are hedges on either side, and to the north, behind you, is what used to " << endl << "be the entrance." <<
" You attempt to open the door." << endl <<
"Though you put all your strength into it, the door has been sealed off and you " << endl << "cannot go back."
"The only way, it seems, is forwards." << endl << endl <<
"Press 'S' to go south" << endl << endl << "->";
char dir;
cin >> dir;
if (dir == 'n' || dir == 's' || dir == 'N' || dir == 'S')
{
movechecky ( x , y, dir, maze1);
}
else
if (dir == 'e' || dir == 'w' || dir == 'W' || dir == 'E')
{
movecheckx ( x, y, dir, maze1);
}
char dummy;
cin >> dummy; // keeps cmd window open
}
Alex- Posts : 67
Join date : 2012-02-23
Location : Come at me bro
Re: function call errors, HELP!
What's the error? cos it's compiling for me :S
Alex- Posts : 67
Join date : 2012-02-23
Location : Come at me bro
Re: function call errors, HELP!
Ugh. never mind. Tried editing my current solution and it failed.
Created a new one using only your code and it was fine. I have no idea where the problem was in mine, but this works fine.
Thanks very much =)
Created a new one using only your code and it was fine. I have no idea where the problem was in mine, but this works fine.
Thanks very much =)
VicVic- Posts : 17
Join date : 2012-02-28
Re: function call errors, HELP!
'Thanks very much' doesn't really cut it.
I was getting so damn stressed about it, because I couldn't figure the problem myself. The relief is unbelieveable haha!
<3
I was getting so damn stressed about it, because I couldn't figure the problem myself. The relief is unbelieveable haha!
<3
VicVic- Posts : 17
Join date : 2012-02-28
Re: function call errors, HELP!
No problem I'm like a code machine provided people say thanks and I'm not doing the same thing repeatedtly (like the algorithms cw ._.)
Alex- Posts : 67
Join date : 2012-02-23
Location : Come at me bro
Re: function call errors, HELP!
xD oh god. I actually understood algorithms myself in the end. Explaining it to people on fb was not fun!
Now I just need to make movecheck WORK. Tested it using a valid movement. Seems my errorcheck is overzealous..... xD
Now I just need to make movecheck WORK. Tested it using a valid movement. Seems my errorcheck is overzealous..... xD
VicVic- Posts : 17
Join date : 2012-02-28
Re: function call errors, HELP!
Ah your maze check isn't working because in the if statements you are doing
if (maze1[x][y-1] = 0)
instead of
if (maze1[x][y-1] == 0)
if (maze1[x][y-1] = 0)
instead of
if (maze1[x][y-1] == 0)
Alex- Posts : 67
Join date : 2012-02-23
Location : Come at me bro
Re: function call errors, HELP!
...God DAMNIT.
xD
I am useless sometimes! Thanks again
xD
I am useless sometimes! Thanks again
VicVic- Posts : 17
Join date : 2012-02-28
Re: function call errors, HELP!
Omg. Every time I fix something, another thing breaks. Error code LNK1104
Googled it and found something about changing the Additional Dependencies under Configuration Properties -> Linker -> Input.
It said to put quotes around a particular file directory, but I don't have that directory in the box. I am lost.
http://stackoverflow.com/questions/133698/why-does-fatal-error-lnk1104-cannot-open-file-c-program-obj-occur-when-i-c is the page i was looking at.
Additional dependencies are:
kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
Sorry! I came on here to ask about one thing, and now I've got you fixing all my errors.... I'll pay you back, promise.
Googled it and found something about changing the Additional Dependencies under Configuration Properties -> Linker -> Input.
It said to put quotes around a particular file directory, but I don't have that directory in the box. I am lost.
http://stackoverflow.com/questions/133698/why-does-fatal-error-lnk1104-cannot-open-file-c-program-obj-occur-when-i-c is the page i was looking at.
Additional dependencies are:
kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
Sorry! I came on here to ask about one thing, and now I've got you fixing all my errors.... I'll pay you back, promise.
VicVic- Posts : 17
Join date : 2012-02-28
Re: function call errors, HELP!
Copied every source file over into a new solution and it works fine.
I wonder where the fuck that error came from....
I wonder where the fuck that error came from....
VicVic- Posts : 17
Join date : 2012-02-28
Re: function call errors, HELP!
LNK1104 sometimes crops up for me, it's annoying, I forgot how I get rid of it, but at least you got it sorted
Alex- Posts : 67
Join date : 2012-02-23
Location : Come at me bro
RUSES :: Part 1 :: Programming :: Coursework
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum