C :: How To Turn Up Error Checking On IDE
Dec 8, 2013
The reason being is that it says that my program is right
Code:
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#define NFlights 10
struct date {
int month;
int day;
int year;
int hour;
int minute;
[Code] ....
View 6 Replies
ADVERTISEMENT
Feb 14, 2013
How would one cycle through a turn order in a turn-based game? I was thinking an array of every creature (including the player) and have a pointer to the array++ after the turn, but I couldn't put all the objects into an array.
View 2 Replies
View Related
Jul 10, 2014
map< int, int > cache;
int count( int n ){
if( cache[n] != 0 ){
return cache[n];
[Code] ....
I don't know how to turn this recursive function into an iterative...
View 7 Replies
View Related
Feb 22, 2015
I am trying to include all repetitions for just one turn but I keep getting
00.0 but I want (the one in red)
170.3 0 0.3
180.0 17 0.0
190.3 18 0.0
200.3 19 0.3
210.0 20 0.3
220.0 21 0.0
22 0.0
so basically I call a function that represents just one turn of getting a random number, and then when the player decides he wants to get a random number that is at least 17 and wants to repeat this 3x I have to print out this chart that shows the chances of the player rolling the numbers between 17-22 [how many times does he get 0,17,18,19,20,21,22] this is what I have
cout << "your score: " << (' ') << "chances for that score:" << endl;
/* score is the player's total score for the one turn */
int score = 0;
int score0 = 0; // 0
[Code]....
View 3 Replies
View Related
Mar 28, 2013
Say you the user inputs x number of names and then is to put in x amount of values for each name. How would you display these values in a 2d array and be able to add the values for each row which will represent each name?
View 5 Replies
View Related
Jul 23, 2013
int main () {
string integer1;
string integer2;
cout <<" enter your first number: " << endl;
cin >> integer1;
cout << endl;
cout << integer1 << " is your first number" << endl;
}
Now how do I turn the string integer into an array?
View 5 Replies
View Related
Dec 9, 2013
I'm having trouble trying to turn a word into letters. I've seen other posts but they deal with a sentence and it only outputs the words only. What I want to know is how do they take a word (Ex: "word") and break it into individual letters, where I want to store them in a vector of string?
If it's not too much trouble, I would prefer without using pointers or "std:: " marks, since I am trying to avoid pointers and I'm using "using namespace std" all the time.
Ex:
In the example "word", it should output into:
"w"
"o"
"r"
"d"
and I will push them back into a vector of string where each vector element contains a letter.
View 2 Replies
View Related
Mar 2, 2014
I know strings are essentially just arrays of characters, so what would be the easiest way to take each individual digit and put it into a separate space in an array?
ex.) *str = "90210"
array[0] = 9
array[1] = 0
array[2] = 2
array[3] = 1
array[4] = 0
All my attempts at achieving this just result in an array full of garbage numbers. What I've done is
Code:
int *array;
array = malloc(sizeof(int)*(strlen(str));
for(i=0; i<strlen(str); i++) {
array[i] = str[i]
}
also, I should mention that the string will be defined in main, and its converted into an array in a separate function.
View 2 Replies
View Related
Dec 11, 2013
[URL] ....
This is my code, but how can I implement this?
View 1 Replies
View Related
Sep 12, 2014
I am starting a turn based battle (similar to pokemon) app. How could i make this and make it cross platform. Also is it possible to make it access gps and allow other devices with the same app communicate with each other?
I have done things on the command line but i never made anything with images so i dont even know where to start for this app.
View 4 Replies
View Related
May 16, 2014
So basically it consists of implementing a single turn for the game called 'pig' and printing out scores and probabilities of those scores. So this is what I have thus far :
int randomNum (int min, int max) {
return min + rand () % (max - min + 1);
} int singleTurn (int holdValue) {
int totalRoll = 0;
int score = 0;
do {
score = randomNum(1,6);
[code]....
View 13 Replies
View Related
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
Jul 10, 2013
So I wrote a program to turn a binary file's data into an unsigned character array for inclusion in an executable. It works just super.
I'm wondering how I can write a program that will perform this operation on every file in a directory and all it's sub-directories so that I can I can include everything I need all at ounce.
View 9 Replies
View Related
Sep 19, 2013
I usually check if a bit is set using:
Code: bit = (number >> n) & 1; where `n` is the bit I want to check...
But I came across a stackoverflow answer saying:
bit = number & (1 << x); will not put the value of bit x into bit unless bit has type _Bool (<stdbool.h>).
Otherwise, bit = !!(number & (1 << x)); will..
So why is this? why the double !?
View 5 Replies
View Related
Nov 4, 2013
Everything seems to be correct from my perspective. heres the program: Code: /*c program to check whether a string is palindrome or not*/
#include<stdio.h>
#include<string.h>
int main(void) {
char str[30];
int i,j,flag=0;
[Code] .....
View 1 Replies
View Related
Jun 15, 2013
Q. In context of C language syntax checking, which of the following can be modeled using Finite Automata?
(A) Detecting proper termination of an instruction.
(B) Detecting balance of parentheses.
(C) Detecting initialization of a variable.
(D) None of the above.
View 4 Replies
View Related
Jan 31, 2015
I am new to C++ , i want to know how to check if a key with modifier is pressed.
When I use GetAsyncKeyState() it gives me error identifier not found.
View 1 Replies
View Related
Aug 4, 2013
I think I may have found a new way of checking for 3d polygon collisions, but I'm not sure. The method involves...
1. finding the planes that the primitives lie on
2. finding the line where the planes intersect
3. if both polys have points on both sides of the line AND have points that overlap on the 1d space of the line, then they intersect.
I have some half done code testing this, and so far it seems to be sound and fairly fast. These are some average time-tests done on my machine for each part:
1. 30 microseconds (both)
2. 7 microseconds
3. TBD
View 5 Replies
View Related
Jun 17, 2014
I have a question, how can I check if a program is running using c++? For example
if (notepad.exe is running) {
.... ..... ....
View 3 Replies
View Related
Jul 20, 2014
How would I go about checking for deallocated memory?
For example, let's take this into consideration:
// Unsigned 32-bit / 64-bit integer: uint32, uint64
uint32* Pointer = new uint32[ Size ];
uint64 MemAddr = ( uint64 ) Pointer;
delete[] Pointer;
The above code would proceed to create a new array, store it in a pointer and retrieve the memory address of the array before finally deleting the array.
So let's assume we re-build the pointer and try to access the now deallocated array:
Pointer = ( uint32* ) MemAddr;
Pointer[ 0 ] = 0;
Based on the above snippets of code, how would I check "Pointer" after rebuilding the memory to check if the rebuilt memory has actually been deallocated. Without a check we'd get an exception error.
A bit of detail on why I am trying this:
Before thinking up how to do this, I was storing the addresses in a list and check the list for the addresses to see if they existed or not. However this requires an O(n) search, which isn't exactly what I am wanting. So instead if I used a check for deallocation method, I can go for an O(1) time check and reduce the total time it would take to check for memory allocation/deallocation.
View 11 Replies
View Related
Jan 23, 2014
I have created a prompt which prompts the user for an integer and I have set up a loop to check for if it is an integer or not. My "bug" is that a user can enter an "integer" and "space" and "enter" and it does not give any error and assumes that "All is FINE!". I have gotten the value from the ascii table of 'SPACE' and put it as a check in my parameter of while, but it does not work.
Here is my code:
int x, y, boolean, i;
char buff[256];
printf("Enter the first integer value: ");
scanf("%s", buff);
i = 0;
boolean = 0; //initializing our boolean var that will eventually decide if we have an error or not
[code]....
View 4 Replies
View Related
Mar 6, 2014
Suppose you have a templated class, such as
template <typename T>
class Matrix {
// some stuff and some methods
};
and let's say that you have some methods that need to do some type-dependent stuff, like, for example,
template <typename T>
Matrix<T> Matrix<T>::transpose() const {
// get this->rowCount, this->columnCount
// create a Matrix that has rowCount amount of columns and columnCount amount of rows
// copy (*this)[j][k] to theMatrix[k][j] (for all of the entries in *this)
// if the entries are complex, take the complex conjugate of them all
}
Would it be good practice to check explicitly for the typename parameter (or is this, somehow, defeating the purpose of templates)? std::cout << "I know that this is a design question, but it needs to be asked... ";
View 1 Replies
View Related
Mar 1, 2015
I'm playing around with parts of code and am coming across some errors. Most of my concern is related to strtok(). I've used it before but with a char* named token. I used a while loop to continuously check whether token was equal to NULL. In the following code, however, there aren't any checks. I was wondering if that is why this code prints (null) while running. Also, I would like to know if it is possible to read input like this code attempts to do - assigning tokens to each variable one after the other.
The format of the input:
Zucchini, Squash, pound
Yellow, Squash, pound
Tomatoes, Ugly Ripe, each
#include <stdio.h>
#include <stdlib.h>
[code]....
View 3 Replies
View Related
Oct 13, 2013
Assuming I have a list of pointers to a generic type T:
#include <vector>
//...
list<T*> myList;
Now assuming I want to go on the list, and if T's type is matched to the type I'm looking for, then cast it to this type and do something. List shown here:
list<T*>:: const_iterator iter= myList.begin();
for(; iter!=myList.end(); ++iter){
if( typeid(*iter)==typeid(Something*)) //RUN-TIME ERROR
dynamic_cast<Something*>(*iter)->DoSomething();
}
how do I fix this run-time error?
View 1 Replies
View Related
Feb 14, 2014
#include <iostream>
using namespace std;
int main(){
int x;
cout << "Enter character:";
cin >> x;
[Code] ....
If i type in:
+
How come it says that "this is not addition?
View 5 Replies
View Related
Jun 5, 2013
I have this table Profile which has fields with user_Id and regNo and I want to check first if id and email are already exists before proceed to inserting datas. In my codes, I am able to validate only one row (either id or reg number), but if I am going to validate the two of them, it gives me an error, saying "Must declare the scalar variable @userid". I dont know if it is with my select that is wrong or something in my codes
SqlConnection con = new SqlConnection("Data Source=GATE-PCSQLEXPRESS;Initial Catalog=dbProfile;Integrated Security=True");
con.Open();
SqlCommand cmdd = new SqlCommand("select * from Profile where user_Id = @userid AND RegNo = @reg", con);
SqlParameter param = new SqlParameter();
[Code] .....
View 3 Replies
View Related