C :: Labyrinth Creator Does Not Work Properly

Dec 16, 2013

this programm should in theory create a labyrinth but it doesnt and i really dont have the skill to pick up where i have been mistaken so gcc runs it but it crashes and it doesnt produce any remarkable results even when it runs....
for example this should you run it with these parameters .

5
5

appear something like this
10111
10101
10101
10001
11111

or like this

10111
10001
11101
10001
11111

but it only crashes....it works with recursion and it makes a array (which is Ptr) a set of 1 and 0 which 0 is the path and 1 is the walls...

Code:
#include <stdio.h>#include <stdlib.h>
#include <time.h>
int **Ptr;
int M, N, P, charge, i,c,j;
void Lab_creator(int vertical, int horizontal,int direction);

[Code] .....

View 2 Replies


ADVERTISEMENT

C++ :: Expression Creator That Prints The Work Out Too With Answer

Nov 24, 2014

I am trying to create an expression creator that prints the work out too, not just the answer.

Code:

#include <iostream>
#include <windows.h>
using namespace std;
void p1();
void p2();
void p3();
double P,P2,p,ans,ans2,ans1,restart;

[Code] .....

View 4 Replies View Related

C :: Cannot Get Strstr To Work Properly

Aug 26, 2014

I am unable to get the string seaching function to work. it always says "Nothing found" I am stumped.

Code:

#include <stdio.h>
#include <string.h>
char tracks[][80] = {
"I left my Heart at Harvard Medical School",
"Newark, Newark, You suck balls",
"Dancing with a dork",
"From Here to maternity",
"The Girl from Iwo Jima",

[Code]....

View 3 Replies View Related

C++ :: Print Function Does Not Work Properly

May 21, 2013

This is my code for submitting students but when i use search function the course member is empty

Code: #include "windows.h"
#include "iostream"
#include <io.h>
#include <sstream>
#include <conio.h>
#include <stdlib.h>
#include <iostream>
#define SIZE 5
using std::cout;
using std::cin;
using namespace std;
int menu();

[code].....

View 11 Replies View Related

C :: Qsort Function Won't Work Properly

Mar 20, 2013

i am facing some problem with qsort() function it work well if the last element of array is larger then the 2nd last element. But in case if last element of array is smaller then the 2nd last it will sort the whole array and remains the last as it is. For example

Code:
int group_id_local[max_j]={2,1,4,5};// it work fine, output should be {1,2,4,5} but if i have this one

int group_id_local[max_j]={2,1,4,3};
// output should be {1,2,4,3}
/* COMPARE FUNCTION FOR USING QSORT()*/
int cmpfunc (const void* a, const void* b)
{
if (*(int *)a < *(int *)b) return -1;
if (*(int *)a > *(int *)b) return 1;
return 0;

[Code]....

why it will not sort the last element?

View 5 Replies View Related

C :: Delete Each Element In The List Which Is Same - Function Does Not Work Properly

Jan 18, 2014

Code:

struct lista* del(struct lista* p, char* path1) {
char model[MAX2];
int len;
char ch;
printf("Type model.

[Code] ..... t

This function should delete each element in the list which is the same as this one typed by user. There are no errors, but function doesn't work. It deletes something, but not this element which should.

View 5 Replies View Related

C :: Create Labyrinth And Player Who Needs To Go Through The Map Collecting Objects

Jan 1, 2015

I actually need to create a labyrinth and a player who needs to go thru the map collecting objects (like bags, water etc...). I planned to do the map with a bidimentional array (5x5) but I dont know how to put different objects on an index.. Ex: array[3][2] will have a Botte of water and an energy bar..

Someone told me to use structs but I dont really understand how this would work... I've tried so many times bit I cant do it...

View 2 Replies View Related

C++ :: Library Not Found In QT Creator

Jan 23, 2015

I am trying to link OpenCV to my qt project, but for some reason it doesn't seem to able to find my files. my .pro file looks like this

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = opens
TEMPLATE = app
INCLUDEPATH += /usr/local/include
HEADERS += mainwindow.h
LIBS += -lm -lopencv_core -lopencv_highgui -lopencv_video -lopencv_imgproc
SOURCES += main.cpp
mainwindow.cpp
FORMS += mainwindow.ui

I get the error message saying library not found for -lopencv_core and it is the same for the other ones.

I've been following this guide : [URL]

What is going on?

View 4 Replies View Related

C++ :: QT Creator - Declare QByteArray Variable

Mar 19, 2014

I am using Qt Creator with VS2012 compiler.

I declared a QByteArray variable : T

I initialized it. Everything OK. I added the line :

Code:
T += "
";

What follows gives me an exception and I think that the issue comes from this added line. As I take a look at T in the debugger, I don't see any but a point .

View 8 Replies View Related

C++ :: Simple Playing Card Deck Creator And Shuffler

Aug 10, 2014

This is a playing card deck creator and shuffler i made yesterday. It is very simple now, but i believe that it could easily be implemented into a card game program of some sort.

#include <iostream>
#include <cstdlib>
#include <cstring>
#include <ctime>

#define STANDARD_DECK 52

[Code] .....

View 1 Replies View Related

Visual C++ :: PDF Creator Printer - Setting Print Options

Apr 12, 2014

I am using PDF Creator printer to print my files. I have set it as default printer. It displays two dialogs .. "Printer Setup Dialog" and "Dialog asking filename and other details to save to file".

I want to avoid these two dialogs. But EndDoc calls the other dialog by default. How to do this ?

View 13 Replies View Related

C :: String Not Validating Properly?

Mar 5, 2013

1. In main() in the while loop entering 'q' does not exit.

2. in the isbnValidation function. The size check for minimum length words will work, but the check for "Invalid ISBN character" doesn't.

3. Every ISBN entered returns as valid. The formula is supposed to multiply the first digit by 10, next by 9 etc (skipping all the dashes) and add up to a weighted total which if valid will divide evenly by 11.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ISBNMIN 10
#define ISBNMAX 14

[Code].....

View 4 Replies View Related

C++ :: File Is Not Reading Properly?

Mar 30, 2013

I have a file which I am unable to read properly. This is binary file so my code is"

#include<iostream>
#include<fstream>
#include<string>

[Code]....

the file to read can be download from this link :

[URL]

The first content of file should be 1 I am missing few content from the begining

View 2 Replies View Related

C++ :: How To Properly Iterate Over A Container

Oct 31, 2013

so i have a container called Source that is of type std::map<std::string, std::vector<std::string>> but when I try to print it with this function:

void Lexer::PrintSource()
{
for(auto Iterator = this->Source.begin(); Iterator != this->Source.end(); Iterator++)
for(auto SubIterator = Iterator->begin(); SubIterator != Iterator->end(); SubIterator++)
cout<< *SubIterator << endl;
}

i get these errors:

Lexer.cpp: In member function 'void Lexer::PrintSource()':
Lexer.cpp:29:42: error: 'struct std::pair<const std::basic_string<char>, std::vector<std::basic_string<char> > >' has no member named 'begin'
for(auto SubIterator = Iterator->begin(); SubIterator != Iterator->end(); SubIterator++)
^
Lexer.cpp:29:76: error: 'struct std::pair<const std::basic_string<char>, std::vector<std::basic_string<char> > >' has no member named 'end'
for(auto SubIterator = Iterator->begin(); SubIterator != Iterator->end(); SubIterator++)
^

View 6 Replies View Related

C++ :: Variable Not Functioning Properly

Sep 29, 2014

#include <iostream>
using namespace std;
int main()
{

[Code]...

For some reason, I get the cout of

321
1

Because of the a++, shouldn't it be

321
2

The second example is what the cout needs to be.

View 1 Replies View Related

C++ :: Properly Exiting A Program

Sep 2, 2013

If I were to exit a program, is it okay if I fail to properly destroy whatever structures were allocated?

For instance, if I do this with SDL, there might be obvious consequences like a dead window perhaps. But if I do this with a POD structure, is it okay?

Also, I realize RAII is supposed to fix parts of this but it's not perfect when environments are suddenly cut off with something like exit(1/0);

View 2 Replies View Related

C# :: Parsing XML File Properly

Apr 11, 2014

I'm parsing an xml file full of payslips and using the data in another application. I've got it all working but I suspect it isn't the most elegant piece of code. I run through the xml file finding a series of "Text" attributes/elements" and then I run through it again finding a series of "Field" attributes/elements, Here is a sample of the code:

For getting the "Text" fields :

XNamespace ns = "urn:crystal-reports:schemas:report-detail";

//
// Get all the Text attributes & Elements
//
foreach (XElement xtxt in xdoc.Descendants(ns + "Text"))

[Code]...

This works fine, I extract all the data I'm interested in and go to do my thing with it. However I really need to know when each record ends and I was doing that by looking for "Text24" in the text fields and "EeRef2" in the field fields, which wasn't very elegant in the first place. Then a "Text16" was added to end of each record which was fine I could just look for "Text16" but now it's apparent that "Text16" isn't always there. I've got it all working for now but I'd prefer to process one record at a time i.e. extract all the "Text" & "Field" values for one record, do whatever I need to do with it, update the xml file to indicate this progress ( if possible ) and then move on to the next record. I've attached a sample of the xml but basically is has the following structure :

<Details>
<Section>
<Text></Text>
"
<Field></Field>

[Code]...

So a record is everything between the first <Details> and the last </Details> with two <Details> and two </Details> in between.

View 2 Replies View Related

C/C++ :: Threading / How To Invoke It Properly

Jun 12, 2012

I'm using MS' optimizing compiler CL 13.10 (one from VCToolkit 2003) along with WinAPI threading functions and is being compiled as a C console program.

I was wondering how to implement threading in a production setting? I've seen and tried various examples, but they all show basically the same thing - startup in main, run their function, clean up, and then the program exits.

I don't know the proper terminology, but I was looking for two maybe three functions to run simultaneously with a loop in main. I tried a small test program and was wondering if it's setup correctly.

A structure is used as the argument for each function.

int running = 1; // global variable  
DWORD WINAPI function_1(LPVOID);
DWORD WINAPI function_2(LPVOID);   
main() {  
   HANDLE hndThreads[2];
   DWORD threadIDs[2];

[code].....

Right now, function_2 is just a copy of function_1's definition. Everything *appears* to do what I want, but is it setup correctly?

View 2 Replies View Related

C++ :: How To Properly Use Pointer To A Particular Function

Apr 4, 2013

#include <iostream>
using namespace std;
int function(int a,int b) {
return a + b;
} bool function2(int a,int b)

[Code] .....

View 3 Replies View Related

C++ :: Checking If A Filestream Was Properly Opened

Apr 9, 2013

I' used to check if my streams are properly opened with a simple:

Code:
if (!file)
std::cout<<"Error message";

However I just realized this is only a valid test if they are initialized with a wrong string and when I tested it:

Code:
int main() {
ifstream f_one("input.txt");
ifstream f_two("not_a_file.txt");
ifstream f_three;

[Code] ....

I didn't get the f_three error message, only the f_two.

how should I check my streams in order to prevent this?

View 6 Replies View Related

C :: How To Properly Put Char Values Into Array

Oct 24, 2014

I'm trying to fill the array "g" with letters from the array "letras" given a certain condition. Everything is working fine, except I couldn't do it... Strange characters appear when I run the code. What am i doing wrong?

Note: This is a part of a function. "vetor" is a parameter that was passed to this function.

Code:

int i;
int j = 0;
char g[20];
char letras[5] = {'a', 'b', 'c', 'd', 'n'};
while(j < g)
{
for(i = 0; i < 80; i = i + 4)

[Code]...

View 3 Replies View Related

C :: String As Parameter Not Working Properly

Oct 19, 2013

I want to alter a string inside a function, but it is not working.Here is the function:

Code:

#include <stdio.h>
void test (char *ch){
ch[0] = 0;
ch[1] = 1;
ch[2] = '';
}

[code]...

View 2 Replies View Related

C++ :: Array Not Storing Values Properly

Jan 4, 2013

For some reason the integer array, arr[100][50], declared in main is not storing the correct values when passed through the function charArrayToIntArray.

I made an output right in the function to show how the array is not keeping the proper values, although when I output the array from within the loop in the function, it shows the correct values.

/*
infile.txt:
37107287533902102798797998220837590246510135740250
46376937677490009712648124896970078050417018260538
74324986199524741059474233309513058123726617309629
91942213363574161572522430563301811072406154908250
23067588207539346171171980310421047513778063246676 ...........

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <cstdio>
#include <sstream>
#include <iomanip>

using namespace std;
void fileToCArray(string carr[100]); // from text file: inputs the 100 50-digits number into an array of 100 50-character

[Code] ....

View 4 Replies View Related

C++ :: How To Properly Cite A Source In Code

May 24, 2013

For example, if one researched how to deep copy a map container and paraphrased a solution from a website, what is the proper format? Are there standards for citing works in code?

I am currently only citing the link to the source in my personal code and explaining what algorithm the source contains.

View 4 Replies View Related

C/C++ :: Right Hand Maze Not Working Properly

Nov 1, 2014

I am creating a right hand maze solution, and it actually works for the most part, but it gets stuck at the sixth spot and will not proceed any further. I cannot seem to find my error even though I know it's probably a small one in my code, here is what I have at the moment:

#include "stdafx.h"
#include <iostream>
#include <Windows.h>

[Code].....

View 6 Replies View Related

C# :: How To Properly Handle Thread Failures

Feb 9, 2015

I have an application that uses an array of threads to call a method along with thread.join(). I was just wondering what would be the best way to handle the thread in case if one of the thread fails? Should I put a try catch block on the method that is being called or should I put the try catch block on the array of threads, or is there any other proper way to handle failed threads?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved