Click here to Skip to main content
15,746,107 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Experiment to time how long it takes players to find their way out of a fixed MAZE USING DEVc++
1. You should write a C-program to create a fixed maze of size 25 × 40 and place the @ symbol at
the entrance of the maze as shown in diagram below:
2. You should define four keys on the keyboard for moving in the left/right/up and down directions
so that you can move the @ character in order to find your way through the maze till the exit
3. The program should time how long it takes for a player to reach the exit point and should compare
this value to the previous scores which may exist in a text file and inform the player how many
people who have played before has done better than him/her. Last player’ score should also be
appended to the existing scores of the earlier players that are already in the text file

What I have tried:

#include <stdio.h>
#include <time.h>
#include <conio.h>
void up_loc(char b,int *x,int *y){
    char g=b;
if(b== 'w'){
        else if( b=='d'){
         else if( b=='a'){
         else if( b=='s'){
void main() {
    time_t start_time, end_time;
    start_time = time(NULL);
     int i,j;
    int ans[2]={24,39};
    int x=0,y=0;
     char b;
    while (x!= ans[0] && y!=ans[1]){
    for (i=0;i<25;i++){
        for (j=0;j<40;j++){
            if (i == x && j == y){
            else if(j!= ans[1] && i!=ans[0]){
         scanf (" %c",&b);
    end_time = time(NULL);
    double elapsed_time = difftime(end_time, start_time);
    printf("Elapsed time: %f seconds\n", elapsed_time);
Updated 28-May-23 18:20pm
PIEBALDconsult 28-May-23 20:20pm    
Yeah, and? It's your homework you do it.
Dave Kreskowiak 28-May-23 21:50pm    
And the question is...? You haven't explained a problem you're having so it's pretty much impossible to tell you anything useful.
CPallini 29-May-23 4:06am    
You failed to report the 'diagram below'.

1 solution

While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

And the code you show doesn't appear to be even slightly related to the assignment. Where is the fixed size maze you are instructed to create in the first part? Without that, you can't even begin to start the second part. and this doesn't do that:
int ans[2]={24,39};

Go back to the assignment and read it again: then throw that code away and start by doing exactly what it tells you to.

And do yourself two favours:
1) Indent your code properly and consistently. It makes it a lot easier to read and that means more reliable and maintainable.
2) Stop using single character names for all variables: use names that are descriptive of their purpose.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900