I am making a simple arkanoid game. When the ball hits the block, i want the block to disappear. How would i go around this? i am working in visual studio. I got the collision and everything working.. Here is my code;
int main(int argc, char** argv){
//initialisation SDL_Init(SDL_INIT_EVERYTHING); SDL_WM_SetCaption("Graphics Window",NULL); //set name of project
I'm trying to make a character array, and be able to custom fill it by using the scanf() function to ask the user for each character spot in the array.
Code: #include <stdio.h> int main() { int i; char character_array[11]; char *charpointer; charpointer = character_array;
[Code] .....
And this is the output i get when i run it:
Code: root@kali-Tulips:~# ./myown what letter would you like in the [0] spot of the array? : a what letter would you like in the [1] spot of the array? : what letter would you like in the [2] spot of the array? : b what letter would you like in the [3] spot of the array? : what letter would you like in the [4] spot of the array? :
[Code] .....
Obviously I'm trying to grasp C programming and am very new. I don't understand why this isn't working, and i think its more than my lack of knowledge of C syntax. I believe the correct memory is allocated but when examined with gdb i don't find what i expect....
I am an IT student currently learning linked list. I have a problem with my code here. After I call addFront() my list doesn't change when I display it. How do I somewhat change/fill my list without changing the function type? I know it works on pointers still messed up with linked list.
I know that it is possible to pass a class instance to a function, but in my experience, if said function changes any variables of the class, they don't actually get changed. For example, we have class object, that has a member int number = 5. Lets say we have two functions, func1() and func2, which are not members of class object. If we pass object to func1() which, lets say, increases number by 5 (so now number = 10), at the end of that function number still = 5.
Is there a way to bypass this and have functions alter class variables permanently?
I know that I can pass variables by reference, but, in my experience, such a thing does not work with vectors (which I am also dealing with), so simple passing the desired variables by reference won't work.
I am so close to finishing this program. It will find the median of an array of 5 values. I have one last error that I cannot seem to get to go away. Here's the code:
#include <algorithm> #include <functional> #include <array> #include <iostream> using namespace std; int main() { int integer1, integer2, integer3, integer4, integer5;
[Code] .....
The error states: "IntelliSense: no instance of overloaded function "std::nth_element" matches the argument list, argument types are: (std::_Array_iterator, std::_Array_iterator, unsigned int, std::_Array_iterator)
I have a struct called Array and I'm to create a function to create a dynamic array that's fill with randomly generated integers from 0 to 50 (inclusive) and a function to destroy the array for freeing its memory. Below the code that I have written so far.
Code:
* Struct */ typedef struct {int *pArray; //the dynamic array int length; //the size of the dynamic array}Array; /* Function to create a dynamic array */ Array *initializeArray (int length) {int i; }
I'm having some issues with my code. For the produce function i am getting an error saying 'no instance of overload function produce() matches the argument list' and also for the lines buffer[head].data = message; buffer[head].time = current_time i get an error saying 'expression must have pointer to object type.
In the code i'm not sure if i passed the variables to the function correctly. I have attached the code .....
Hey I am trying to use the getline() function to read a line from a file. For some reason Visual Studio 2010 gives me the following error. "No instance of overloaded function "getline" matches the argument list". The piece of code that produces the error is in a class in a separate .h file and is executed as a method of the object. I'm almost certain it has something to do with either the compiler thinking I am calling another getline in a different namespace or my parameters for the function are incorrect. Here is the code:
Code: #include <iostream> #include <string> #include <vector> #include <fstream> using namespace std; class InsultGenerator
How to construct a simple hash function ? When the program executes, it will ask for your name. Type your name and it will print out a "hash code" (a number) from that name.
So, according to standard the temporary objects should not be destroyed before full expression execution (expression whitch is not a part of another expression).
The question is: is StreamLogger() << "foo1" << "foo2" << "foo3"; full expression or not?
It fills the singly-linked list with 0 through 9 and calls a function to prompt the user to search for a number. I don't see any glaring errors, I was just wondering what could be done to simplify it or if there's anything I missed.
I am facing a real-life problem, it can be simplified as below:
#include <iostream> using namespace std; class B; class A { public: void f1(A a) {} void f2(B b) {}
[Code]...
There is no problem at all with the f1(), it compiles and executes without any problem. But f2() gives compilation error. How to solve this?
The error message is: error: 'b' has incomplete type This is just to define the function f2() in a class, that uses an instance of its child class as one of its arguments.
I'm trying to pass my structure to a function using switch method, so that It will ask for user's name and age then then from the switch method it will call a print function, but my coding is not working.
Code: const MenuData breakfast[NUMOFBREAKFASTITEMS] = { {"Egg Breakfast", "Two eggs with a side of bacon and two slices of toast.", "", "2 Eggs, 2 Toats, 2 Bacons", "", 250.00}, {"Pancake Breakfast", "Three Buttermilk pancakes served with butter and syrup.", "", "Three Pancakes, Butter, Syrup", "", 200.00},
[Code]....
What I'm trying to do is call the printReceipt function in the main, but I'm doing it wrong. Here is my attempt.
I am trying to wright a program that takes student grade data from a command line file, calculates a final grade, and copies the final grades to an output file. So far I have two functions, one that creates a student structure by allocating memory for it and returning its address, and one that should take that address and fill it with data from a line from the input file. My ultimate goal is to use a linked list to connect all the structs, but for now I just want to get the functions working. When I run what I have so far, I get an error C2440 (using visual 2010) that says "cannot convert from 'cStudent *', to 'cStudent', and points to the line where I call my fill function. How should structure pointers be passed?
I am having problems with my function definition of a function that should return a structure value.
This is the error I get compute.cpp(9): error C2146: syntax error : missing ';' before identifier 's_advertisebus'
The error is on the line where I start my function definition typing my function type as a structure. A long time ago in c the keyword struct is used with the structure type like struct s_advertisebus s_readadbus(). I tried it both ways but I got errors.
// struct.h #ifndef STRUCT_H #define STRUCT_H
struct s_advertisebus { int nnumberofads; float fpercentused;
I've been able to write the program completing all requirements except for one... creating a function that accepts a nested structure array. Here's the program:
This works if the function pointer being passed to the event manager is not a member function.
I have two other classes Scene and Object that could potentially use this EventManager to create callback events. Scene and Object are both pure virtual objects. How can I pass a pointer to a member function of the child classes of both Scene and Object? I am fine with just having two separate watchEvent functions for Scene and Object but how do I pass the type of the Object or the type of the Scene? The child classes are unknown as they are being created by someone using this game engine.
For example, if I want to make a player object it would be something like
class PlayerObject : public Object{...};
Now that PlayerObject type has to find its way to PlayerObject::functionToCall(). I think I need templates to do this but, since I never used them before
This is how I intend to use this
class OtherScene : public Scene{ void p_pressed(void){ //pause }