C++ :: Why Is Basic Battle System Failing (no Compile Errors)

Aug 4, 2014

Here's the source code from "battle.h" (which should probably be renamed to "animal.h")

Do you think I made my errors here or in one of the many other headers or cpp?

#include "Identity.h"
#include "stdafx.h"
#ifndef battle_h
#define battle_h
int numbers1 = rand() % 5;
int numbers2 = rand() % 7;
int numbers3 = rand() % 9;
int numbers4 = rand() % 11;

[code].....

View 8 Replies


ADVERTISEMENT

C++ ::  No Compile Errors But Blank Screen On Execute?

Oct 23, 2013

I'm working on a Hash Table implementation and after fixing all the errors and finally getting it to compile and link correctly, I am met with a black screen upon execute.

main.cpp
#include <stdio.h>
#include <string.h>

[Code]....

I tried inserting a debug statement in the main() function to see, and it wouldn't even print out the message "debug me" on the screen.

I am using Code::Blocks on Windows with the mingw32-g++.exe compiler. Here is my build log:

mingw32-g++.exe -Wall -g -c D:MediaDesktopHashElement.cpp -o objDebugElement.o
mingw32-g++.exe -Wall -g -c D:MediaDesktopHashHashTab.cpp -o objDebugHashTab.o
mingw32-g++.exe -Wall -g -c D:MediaDesktopHashmain.cpp -o objDebugmain.o
mingw32-g++.exe -Wall -g -c D:MediaDesktopHashStudent.cpp -o objDebugStudent.o
mingw32-g++.exe -o binDebugHash.exe objDebugElement.o
objDebugHashTab.o objDebugmain.o objDebugStudent.o -mwindows
Output size is 1.06 MB
Process terminated with status 0 (0 minutes, 2 seconds)
0 errors, 0 warnings (0 minutes, 2 seconds)

View 11 Replies View Related

C++ :: Linear Interpolation Code For X And Y Axis - Compile Errors

Oct 15, 2012

When trying to compile, I am receiving errors which I am assuming are pretty generic and common:

lin_interp.c:21: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
lin_interp.c:100: error: expected '{' at end of input

I am just trying to get the code to work for now. I have created a program similar to this which worked in C++, but the code isn't jiving in C.

Code:
// Lin_Interp.c : Defines the entry point for the console application.
//
#include "PACRXPlc.h" /* Include file applicable for all targets */
#include "ctkInitCBlock.h"
#include "string.h"
#include "math.h"
#include "stdlib.h"
#include <time.h>
#include <ctype.h>
#include <stdio.h>
/* Constants / #defines */
// Print-Out on console "XY LIMIT ARRAY" XYlim

[Code] .....

View 8 Replies View Related

Visual C++ :: Compile Time Errors For OpensSSL In Project

Feb 4, 2014

I am trying to build a VC++ project in Visual Studio 2010. [URL] ....

This project has a dependency on openssl libraries. How can I successfully build this project? How to add third party libs/dlls in a project.

View 1 Replies View Related

C++ :: OpenGL Test Code With GLFW And GLEW Compile Errors

Jul 7, 2013

I'm learning OpenGL 3.2+ with GLFW and GLEW.

I'm learning it through this series of tutorials [URL] but when I run the first code:

#include <iostream>
#include <cstdlib>
#include <GL/glfw.h>
#define GLEW_STATIC
#include <GL/glew.h>
int main() {
glfwInit();
glewExperimental = GL_TRUE;

[code]....

(Then i have the glew.h that is about 17000 lines of code)

I get this errors:

c:archivos de programacodeblocksmingwin..libgccmingw324.7.1........includeGLglew.h|84|error: #error gl.h included before glew.h|
c:archivos de programacodeblocksmingwin..libgccmingw324.7.1........includeGLglew.h|1793|error: 'GLchar' does not name a type|
c:archivos de programacodeblocksmingwin..libgccmingw324.7.1........includeGLglew.h|1804|error: 'GLchar' has not been declared|

[code]....

What I'm doing wrong?

View 12 Replies View Related

C++ :: Game Control - Organizational System Giving Errors

Jun 24, 2014

I'm making a game with the following class structure:

GameControl - The class that actually runs the game, with a while(!closed) // run the game loop.

State - A class that handles the state of the game, for example if the game is rendering the scene it would be in one state, and if it is rendering the menu, it would be in another.

ComponentManager - A class that manages all of the components of what is being done, for instance, the Scene class would contain a bunch of components handling the drawing of each tree, physics, the camera, etc. The manager will put them all together.

Component - A component of whatever is being done. A tree (and its rendering code) would be an example of a component of the scene. The camera would be another. The component does not necessarily have to be drawn, it could be handling something like physics (and would throw physics events to other components that need to move in a certain way).

The GameControl class has its loop, which would call the update function on the current State (there are classes that inherit State and override the update function of State).

In the update function of the base class "State", it would take all of the active ComponentManagers and update them. There are classes that inherit the base class ComponentManager and override its update function.

Each ComponentManager would update each of the Components that it owns.

This is the organizational structure that I came up with to make the game scalable and changeable . If, for instance, I wanted to add multiplayer at some point, I would add a class that inherits the State that controls the gameplay called "MultiplayerGameState". This would just add a new ComponentManager that inherits the ComponentManager that controls the player and all of the living things that are moving around. Then, the MultiplayerGameState class would recieve the multiplayer messages coming in and add other player Components for the other players.

My code is giving me various errors like "Forward definition of class State" and "Invalid use of incomplete type State". Unless I made some stupid error that I didn't catch, these are being caused by me including the classes in ways that some of the classes do not see the full definitions of the classes they need to see (because of the preprocessor directives preventing classes from being included multiple times.

Code: (Not implemented exactly as shown above, but I think the main difference is that the main class is not in GameControl, it's in OgreFramework.cpp)

The base classes: [URL] ...
States: [URL] ...
ComponentManagers: [URL] ...
Components: [URL] ...
The project: [URL] ...

My question is: is there a better way to implement my organizational system so that these errors don't occur?

View 1 Replies View Related

C++ :: Battle Simulator - Save / Load Functions Not Working

Oct 16, 2013

I've been working on a battle simulator, and using it as a learning experience. So far, I've been able to debug the program, and learn some stuff, and it's been running smoothly. It's still runnable, but I've been trying to make it so the player can save his character, and continue the game later. However, I'm not sure whether it's the save or load function that's not working, because even if i save to a txt file, it's just a bunch of random characters. I don't know if that means it's not saving correctly, or if it's just supposed to be like that. Anyway, here are the two functions I'm speaking of:

Code:
void Game::saveGame(Character &player) {
std::ofstream saveFile("save.bin", ios::binary);
saveFile.write((char *)&player, sizeof(player));
saveFile.close();

[Code] .....

My program is in multiple files, so I can't really post the whole code easily, but I can upload or something if I really need to.

View 14 Replies View Related

C++ :: Two Player Strategic Battle Turn Based Game - Assigning Controls

Nov 1, 2014

I am making a game which is a two player strategic battle turn based game..... The game will require each player to choose a attack. What would be the best key configuration for set of four attack. Like

player 1: 1,2,3,4;
player 2: 7,8,9,0;
where 1&7 are for kick 2&8 are for punch etc.....
or
player 1: q,w,e,r;
player 2: u,i,o,p;

View 2 Replies View Related

C++ :: Merge Two Sorted Files Failing

Oct 7, 2013

I have to merge two sorted files. Algotrithm that i'm using is below, but it reads not all the numbers in the files, and stops, even the files contain the same number of elements. What is wrong, I can't understand.

ifstream f1("E:desc1.txt");
ifstream f2("E:desc2.txt");
ofstream f("E:desc.txt");
cout <<endl<< "Nuerele sortate: " <<endl;
int n1, n2;
f1 >> n1;
f2 >> n2;

[code]...

desc1.txt is:

99 97 95 93 91 89

and desc2.txt is:

100 98 96 94 92 90

and I'm getting this:

100 99 98 97 96 95 94 93 92

View 1 Replies View Related

C++ :: Binary Tree Heap Destructor Failing?

Feb 5, 2014

I get a runtime error when I add a destructor to my code.

Code:
#include <iostream>
#include <array>
using namespace std;
struct nodes { int* elements; };
class heap

[code]....

View 14 Replies View Related

C :: Passing String To Function (strtoull) Failing

Sep 30, 2013

I have a code in which I am passing string "5368709120" to function strtoull() and it should had returned me number 5368709120 but instead it returns me 1073741824 which is incorrect.

What may be the possible cause of this and how to rectify it?

Code:
typedef unsigned long long
ULL_Type;
char *quotaStr = "5368709120";
ULL_Type quota;
quota = strtoull(quotaStr, NULL, 10);

View 3 Replies View Related

C++ ::  OfStream In Vector Failing To Open File

Feb 20, 2015

I'm trying to move a dictionary into a group of bite-sized files based off of the length of the strings in each file (I'm ignoring strings of length 1 for obvious reasons). Since I don't know what the longest word is (and I'm not going to look for it), and I don't want redundant files, I decided to use a vector of output file streams that I would put all the words into, but I can't get the file to open.

I took a look at it and found the failbit is 1, but the badbit is 0, so apparently it's a logic error on opening the stream [URL] .... I looked online and decided to try using pointers, but that didn't work either, so now I'm asking what the problem might be, because I can't think of any reason why it isn't working.

void createDictionary() {
//declare variables
string dictionaryName;//name of dictionary file
ifstream dictionaryIn;//file of original dictionary
vector<shared_ptr<ofstream>> dictionaryOut;//files where dictionary will be put based off of word length
string word;//input from the dictionary file
vector<int> lengths;//vector containing available lengths and their locations
unsigned long long counter = 0;

[Code] ....

View 2 Replies View Related

C++ :: Memento Pattern Failing Because Of Pointer Data Members

May 24, 2014

All the undos and redos were working fine until the pointer data members came into the picture. The problem is that the values pointed to changed, but the pointers themselves did not. So restoring gives the same pointers but they still point to the new values. I think the solution is that the classes that are the pointer data members themselves need their own Mementos (which would be a lot of work because there are many data member pointers in my program). Is that the only approach?

Here is a sample code to show what I'm talking about. You can compile and run the program to see the problem it has restoring values of pointer data members:

#include <iostream>
#include <string>
#include <memory>
#include <vector>
#include <list>
#include <cstdlib>
#include <ctime>
class FoodHistory {

[Code] ....

View 2 Replies View Related

Visual C++ :: CryptUnprotectData Failing When Code Compiled On Windows 7?

Sep 24, 2012

I have a C++ code that reads the database password from the registry and decrypts it using CryptUnprotectData. We have to deploy this application on a Windows 7 machine.

When I compile my code on Windows XP and run it on the test Windows 7 machine, it works absolutely fine. When I compile the same code on my laptop having Windows 7 and run it on the test Windows 7 machine, CryptUnprotectData fails with GetLastError() return '87'. If I run this application on my own laptop with Windows 7 on it, it again works fine probably because my laptop has a lot of things installed including Visual Studio and all the service packs etc.

I believe I have missed out installing some dependency on the test Windows 7 machine but I am unable to figure out what is that. What is it that's making the Windows XP compiled code running fine on the test machine and not the code that's compiled on Windows 7.

Here is the call to CryptUnprotectData in the code:

if (CryptUnprotectData(
&cipherText,
NULL,
NULL, // Optional entropy
NULL, // Reserved
NULL, // Optional PromptStruct
CRYPTPROTECT_UI_FORBIDDEN,
&plainText))

[code]....

View 10 Replies View Related

C++ :: Implement Member Functions Of Class Function - Failing To Get Input

Aug 17, 2013

I am supposed to implement the member functions of class Person.

class Person {
public:
Person();
Person(string pname, int page);
void get_name() const;
void get_age() const;

[Code] ....

The code I wrote is below. Where I am struggling is the program does not allow me to input age. Therefore, I cannot test if my temp for age works. It automatically defaults to 0 because it hasn't taken input. Here is my code:

// Program Title: Person function
// Program Description: The program prompts the user for first and last name and age.
// It then prints the output that was provided by the user.

#include<iostream>
#include<string>
using namespace std;
class Person {

[Code] .....

View 13 Replies View Related

C/C++ :: Run Basic Stats On 150 Tables

Mar 7, 2014

I need to run some basic statistics on about ~150 tables that are currently in dBase format. Rather than use excel to do them all individually, i was told to use s+ and write a code to loop through them, but I have never written any code and my experience with spotfire s+ is limited (the stat software i have available) ....

View 4 Replies View Related

C++ :: Basic Encryption And Decryption Program

Sep 29, 2013

I am having trouble with an assignment. The assignment consists of a basic encryption and decryption program already written for me, I just have to write the encryption function. What we have to get the program to do is enter an integer and a text, and get the program to increment each letter in the text by the integer given. I did this by using a for loop and incrementing each value in the string by the integer.

However, I still can't get it to decrypt and I need the program to work with only a-z letters (if I increment each letter by 3 and I have the letter Z, it should go to Z+3 = C).

I attached the description of the attachment and below are the codes: The first file does not need to be edited.

Code:
/*******************Programming Assignment 1***************/
/****************Caesar's substitution cipher**************/
/*****************YOU MUST NOT EDIT THIS FILE**************/
/****Substitute alphabets in a string using rotation key***/
/****Leave all other characters unchanged******************/
/****Confirm correct encryption by decrypting**************/

[Code] ......

View 1 Replies View Related

C++ :: Variadic Template Basic Syntax

Jul 31, 2014

I had to learn how to use variadic templates recently, and had trouble finding simple examples that just showed the basic syntax.

So I decided to write one myself. Admittedly, it's a bit on the long side, but that is mostly because it includes five specializations.

insert Code:
// Variadic.C
// Compile command: g++ Variadic.C -std=c++0x
// I used GCC version 4.6.3 on Ubuntu.

// This file contains a basic variadic template with five specializations.
// It is intended for non-software engineers who are looking for a simple
// example of variadic template syntax.

[Code] ....

View 3 Replies View Related

C :: Basic Array Pointers Program

Feb 4, 2014

Code:

#include <stdio.h>
void Swap(int *x, int *y);
int *Largest(int *array, int size);
int main()
{
int a, b, i;
int c[10];
int maxaddress;
}

[code]...

My swap function works fine, but I am trying to find the ADDRESS of the largest element in my array and I am getting an error using gcc on my "return &largest;" and my printf line in my main function.How can I fix this and return the address of the largest?

View 8 Replies View Related

C++ :: Basic Encryption / Decryption - While Loop

Jul 14, 2013

while(!in.eof()) {
in >> ch;
char d = int(ch) + 10;
out << d;

[Code] ....

The first while loop would be to encrypt it, and the second would decrypt it, the decrypting is not giving the original content. For example:

in = Hello
encrypt...
decrypt...
out = Hellooo

View 2 Replies View Related

C++ :: Calculating Net Pay - Adding Basic Procedures?

Nov 18, 2014

So I am currently in the middle of learning c++ and I decided to jump ahead of the book and tried to do add procedures. My goal is to have main calling other procedures such as welcome message().

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

#define MIN_HOURS 0.00 // minimum hours per week
#define MAX_HOURS 60.00 // maximum hours per week
#define MIN_RATE 0.00 // minimum pay rate
#define MAX_RATE 99.99 // maximum pay rate

[Code] .....

View 5 Replies View Related

C++ :: Configure Netbeans Basic Settings

Nov 22, 2013

I want to configure netbeans 7.4 settings for c++.I'm posting here because netbeans forums are close to dead. How to do the following things :-

1) When you create a new project of a 'new application' type, main.cpp is already there with some code. I want that main.cpp to be completely empty when I create a new project.

2) When you compile/build your program and run it, the output is shown in a small log window at the bottom. I want it to be shown like in a black output terminal (console ?) just like in Visual Studio or CodeBlocks. (I have some reasons for not using them instead, so don't bother about me not using them)

3) When you click the green 'Run' icon in the upper toolbar, the project is compiled/build again and then runs afterwards. I want it to just run without compiling. (Compiling/Building should be done by 'Build' icon, just like in CodeBlocks or Visual Studio)

View 3 Replies View Related

C++ :: Make Basic GUI From Scratch Without Using Any Programs?

May 26, 2013

I have learned the basics you need to know about c++ so I was wondering, how do you make a GUI from scratch without using any programs like qt, daniweb, ect. Is there like a ongui() or something?

View 6 Replies View Related

C/C++ :: Basic 2D Array Displaying Output?

Feb 23, 2014

I been for trying to create 5x5 2d array that

basically display first column, last column , and diagonally (like " N " display). but i cant get it to work.
this is what i have so far.

int _tmain(int argc, _TCHAR* argv[]) {
char Test[5][5];
for (int i = 0; i < 5; i++)

[Code]....

View 4 Replies View Related

C/C++ :: How To Do Basic Animation With GTK3 And Cairo Only

Apr 22, 2014

Let assume i have a gtk window with a drawing area and a button in it....

When the application is run it will show ball... when the button is pressed it will start bouncing from one side to other... When the button is pressed again it stop bouncing...

Also the window shows the current XY co-ordinates of the ball in the bottom left corner(inside the drawing area)...

I want to use C , GTK3 and CAIRO only...

I have googled and found animation example not with GTk3 but GTK's previous versions instead...those doesnt work with GTK3..i have also read cairo's official,zetecode's tutorails and some other sites..but nowhere found any solution to my problem...

I know how to do so with OpenGL and it's very easy...but i cannot apply the same logic with cairo and gtk3...please dont suggest to use GtkGlExt...i don't want to use it...

View 1 Replies View Related

Visual C++ :: How To Create A Basic Window

Dec 29, 2012

I want to create a basic window using visual c++ 2010 express.

View 1 Replies View Related







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