C/C++ :: Making Tic Tac Toe Without Arrays?
Nov 13, 2014
I am trying to get this to work without arrays. At the moment all I am trying to do is allow it so that when the user presses 1 the board prints with 1 replaced by X, tell me where am i going wrong. I know its not finished.
#include <stdio.h>
#include <stdbool.h>
char a = '1';
char b = '2';
char c = '3';
[code]....
View 3 Replies
ADVERTISEMENT
Nov 11, 2014
I'm trying to write a code that proves a queue like fifo (first in first out). I have four characters :
p(rint),e(nqueue),d(equeue) and q(uit).
The problem is when I press d a first character must get rid of, but not. When I press d the numbers get double.
Example input:
e 2 3 9 8 7
p
2 3 9 8 7
d
p
3 9 8 7
d
p
9 8 7
#include <stdio.h>
void enqueue(int queue[], int newnum, int *tail_p, int maxsize);
void deque(int queue[], int *tail_p, int *elem);
void printqueue(int queue[],int count);
[Code] ....
View 1 Replies
View Related
Feb 26, 2014
I have a sword(25 damage), spear(20 damage), arrow(15 damage), dagger(10 damage) and knife(5 damage). I want to make a class for them so that I can equip one of them in battle and use them to inflict damage.
View 1 Replies
View Related
Feb 6, 2014
I define "Comwords" as a string, but apparently it takes the members as chars, then I can't set strings in a structure equal to the chars.
I see to also be having unknown problems with the ComMAL array and loading it values into another element of the same structure.
How to correct this? I was thinking of casting char elements as strings, but could find no reference in my library book regarding how to do that (lots on casting int's a doubles...)
Code:
int _tmain(int argc, _TCHAR* argv[]) {
int comm = 10;
int targ = 5;
int death;
struct AI_WORDS
[Code]....
View 2 Replies
View Related
Jul 1, 2014
Using a for loop, construct two 100 element arrays, x and y, such that element i of x stores the value sin(2*pi*i/100)) and the corresponding element of y stores cos((2*pi*i/100)). Print the values stored in the elements of x and y as you calculate them.
I have attempted to solve it but I'm not sure why the value 0 is only being printed, maybe I haven't assigned sin(2i/100)) and cos((2i/100)) to the arrays properly?
Code:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main () {
[Code] .....
View 3 Replies
View Related
Feb 27, 2015
Here's my game, what do I need to learn to make a basic GUI? (Easiest way possible for now).
--NOTE, the code was a bit too long for me to post. I can add it if it is necessary. Basically all I want are 4 buttons on the main screen, one that says "Arena," "Store," "Stats," and "Exit."
There will of course be sub menus to each option, but we will get to that later.
View 1 Replies
View Related
May 28, 2013
I have project that is on c++. it runs fine. i want to use it in my C# application as a dll. i have created its dll and but firing exception of "interprocess communication".
Is this a doable task that creating dll of an exe project and using it in C# application?
View 1 Replies
View Related
Dec 17, 2013
So I tried to find some youtube videos on how to make a DLL, I found one, I also found several topics (like on msdn and stuff), but I have this code
header
#include <WinSock2.h>
#include <WS2tcpip.h>
#include <Windows.h>
#include <string>
using namespace std;
#pragma comment(lib, "ws2_32.lib")
[Code] ....
And I'm getting these errors:
1>error LNK2001: unresolved external symbol "private: static char * PathSocket::cBuffer" (?cBuffer@PathSocket@@0PADA)
error LNK2001: unresolved external symbol "private: static unsigned int * PathSocket::socket" (?socket@PathSocket@@0PAIA)
error LNK2001: unresolved external symbol "private: static void * PathSocket::hIDTask" (?hIDTask@PathSocket@@0PAXA)
WHY is there static, and what does dllimport/dllexport does? also there are NO tutorials with variables inside dll >.<
I've been following this [URL] ..... and the video I already lost, however there's no
#ifdef MATHFUNCSDLL_EXPORTS
#define MATHFUNCSDLL_API __declspec(dllexport)
#else
#define MATHFUNCSDLL_API __declspec(dllimport)
#endif
in the video, why do we have to use that? [URL] .....
View 19 Replies
View Related
Dec 17, 2014
int arr[4][5];
for (int(&row)[5] : arr){
for (int &column : row){
} }
Why do we name it row instead column?
int arr[row][column]
Wouldn't this be like
int arr[4][5];
for (int(&column)[5] : arr){
for (int &row: column){
}
It just seems funny to me because we use row[5] which should be 4 if we meant row? Or did I read it wrong in C++ prime !?
View 2 Replies
View Related
Oct 13, 2014
So basically I have to write a C program that, when opening the html file in a browser, looks essentially like this: (Size, position, color of the shapes doesn't matter so long as I have one of each shape and the box surrounding them. Words up top dont matter either.)
This is what I have so far:
Code:
#include <stdio.h>
#include <stdlib.h>
#define FILENAME ("A4P1.html")
[code]....
Anyways i can get the individual shapes, but I don't know how to get all the shapes to appear at once..
View 6 Replies
View Related
Oct 15, 2013
i have an assignment where i have to draw a teapot using triangles, and are struggling with the part where i have to color it. Here is an link to the assignment URl....
I have managed to draw the teapot and translated it onto the screen. the part i need support with is making a bounding box for the triangle and coloring it.
View 5 Replies
View Related
Apr 22, 2014
I have to make a table for 10 Employees to look like this:
Employee ID Gross Pay Net Pay
101 540.58 480.80
158 796.32 630.20
How can I do this? This is my code so far.
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
void get_emp_rec(int &id, double &prate, double &hours) {
[Code] ....
View 2 Replies
View Related
May 17, 2013
I'm creating a game in which i.need player to.answer.my question within 10 seconds...
So I need a code for this timer... I don't want code to be paused by sleep or delay functions.. But I need that it waits.for 10 seconds.. and if user types answer in between.. it.reads it
And if player.doesn't answers it within 10 sec.. it displays a message
View 2 Replies
View Related
Jun 28, 2014
One exercise says that, "Define a right triangle class. Make an octagonal shape out of eight right triangles of different colors."
Making such a class isn't difficult. I wrote it as follows:
#include "Simple_window.h"
class right_triangle : public Shape {
public:
right_triangle(Point p, int l, int sh): c(p), _long(l), _short(sh)
[Code] ....
But it sounds that making an octagon using eight right triangles isn't possible!
View 2 Replies
View Related
Nov 23, 2013
#include<iostream>
#include<fstream>
#include<iomanip>
[Code].....
make it sort ascening wise for salaries and have the occupation sort with it.
View 6 Replies
View Related
Sep 20, 2014
I wish to create a simple animation, similar to the pong game but completely automatic (i.e. both sides play against eachother sort of like in a screensaver of sorts).
I am clueless on to even start tackling this, what tools to use and how to use them, to make them do what I want. I have had some experience with C++ scripting while modding Fallout 3, but I'm not sure how similar the scripting system available in the SDK for that game, is to the real thing.
Like I was saying I want to create a simple animation where two AI blocks try to prevent a ball from reaching the wall behind them.
View 3 Replies
View Related
Jun 28, 2014
One exercise says that, "Define a right triangle class. Make an octagonal shape out of eight right triangles of different colors."
Making such a class isn't difficult. I wrote it as follows:
#include "Simple_window.h"
class right_triangle : public Shape {
public:
right_triangle(Point p, int l, int sh): c(p), _long(l), _short(sh) {
add(Point (p));}
void draw_lines () const
[code]...
But it sounds that making an octagon using eight right triangles isn't possible!
View 4 Replies
View Related
Nov 19, 2014
What my ultimate goal here is to make a program that asks the user how many numbers they would like to add followed by asking the user what numbers they want to add. I want the amount of numbers they can add to be infinite and have the loop continue adding the numbers until it reaches the final number. I just need to know how to do this.
Here's my code:
#include <iostream>
#include <string>
using namespace std;
int main() {
//variables
int amount;
float num;
float sum;
[code]....
View 3 Replies
View Related
Jan 16, 2015
Code:
class Robot{
char name[15]; //assign to char n
int x, y , direction;
void ToString(int d);
[Code]......
how do i assign char name[] in the class to char n in the constructor?
View 3 Replies
View Related
Dec 15, 2013
Code:
#include <stdio.h>
#include <stdlib.h>
#define CLASS 4
#define STUDENT 11
#define GRADE 5
[Code] ....
Giving me that error on 75:10
avesub+=grade[k];
and 90:17
donkeypunch+=grade[j][k];
not sure exactly why
View 8 Replies
View Related
Mar 6, 2015
I have a problem with making header files in c, i get the code written only in main.c and then i have to create a files with extension .h and extension .c but how to do it.
View 4 Replies
View Related
Nov 24, 2014
I have a 2D array, array[20][3]. Each row represents a storm and each column represents month #, wind speed, and pressure in that order. This data is read from a file and auto-fills the array. I need to be able to give users the ability to add an additional storm or delete a storm. I know that a linked list would be the best approach but I'm not very familiar with linked lists.
View 1 Replies
View Related
Oct 20, 2013
As the title says im trying to make a self balancing robot.
I am using an accelerometer and a gyro as sensors.
I am just really confused when it comes to programming in a PID loop to actually use feedback from the sensors to control the motors.
I sort of understand what needs to be done concering PID loops, just i dont know how to do it.
View 9 Replies
View Related
Oct 15, 2013
Here's what I have to do: Using strcpy() pass it two strings of characters (such as a name like John Johnson) and copy the second string into the first, in reverse order, and print both. Write a main to exercise your function and to illustrate that the function is working properly.
View 4 Replies
View Related
Oct 16, 2013
I know there is a function for comparing string but i am making it to just improve my concepts.error : 2 is coming as answer when i put same sting in both place.
Code:
#include<stdio.h>
main()
{
char str1[] = "hello" ;
char str2[]= "hello" ;
int q;
q = xstrcmp(str1,str2);
printf("%d",q);
}
[code]....
View 5 Replies
View Related
Feb 20, 2013
As part of class project I'm working with the following code...
Item.h
#ifndef ITEMH
#define ITEMH
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
[Code] ...
The plan is to add a new method 'resize' where a new array will copy the contents of the first original array and modify the already existing 'add' method to call 'resize' when necessary.
Up till now, in the constructor I created the new array, should I give the array a default value?
View 5 Replies
View Related