this is a piece of code from my program for a game of quiz...this class is supposed to manage the marks of a player. i am passing marks for a question depending on its correctness to the setscore function and i want it to keep on updating the value of m_score so that finally i can return it from the getscore function....with this piece of code i am getting some junk values being returned by the getscore function .
class Player
{
private:
char* m_name;
int m_score;
public:
friend class Scoremanager;
I am trying to read data from a smartcard using scardTransmit. But the data read is always 6D 00 CC CC (Be it for name, expiry date or any other data, always the same.) This is probably some junk data?
I passed an array from a function from a class and i am using the object of that class in other file but when i pass it the values of that array are coming ssome junk values (i think) i ll show u the usage :
// randomno.cpp : Defines the entry point for the console application.//
//#include "stdafx.h" //#include<iostream> #include<ctime> using namespace std; class randomnogen {
I am making a game commonly know as the Hangman using C++.
Now I am trying to add a man in it like this:
0 |/ | /
Now the problem i am facing is that i am using a check that if a function returns the value 0 "return 0" it means the guess is wrong and it will not update the man but if it returns any value there will be a function called which will update the man.
I just wanna know that how i am going to use the check, the kind of thing that i am trying to use is, in general words "if(function returns a value) then update the man"
int main() { return match; }
How are we going to use it in check that if int main is returning 'match' in the check...
This simple little program is not returning a value. The output is
" (string) contains characters" (The number of characters is supposed to display between the 'contains' and 'characters.'
However, if I go to the function and cout the length, the cout in the main body displays just fine.
Here's the main portion :
cout << "'" << input << "' contains "; //Output of character count. charCount(input); cout << " characters, including any spaces. "; //Output of character count.
and here's the function.
int charCount(char *string) { int length = 0; //Variable to hold the number of characters. //Gets the number of characters contained in *string and puts that number into length.
As the title says, i'm using a function which returns a pointer to a struct:
the struct is the following:
Code: typedef struct POINT { uint16_t x; uint16_t y; }
Coordinate; the function i'm using:
Code: Coordinate * Read_XTP2046(void) {static Coordinate screen; //calculations to determine the coordinates screen.x=(temp[1]+temp[2])/2; screen.y=(temp[0]+temp[2])/2; // and so on... return &screen;}
The question is: how do i catch this pointer and make it into a Coordinate struct in which i can read the x and y.
In my main program i would do the following:
Code: Coordinate cor; cor = Read_XTP2046();
This does not work, as the function returns a pointer, but how to transform this pointer into a Coordinate struct.
I need to create a function which will print a list from 100Hz to 1000Hz then 1000Hz to 9000Hz. I have created a function in order to calculate and set up the frequency values from 100Hz to 9000Hz using two for loops as shown below. However I am unsure how to return this to the array at the main.
int main(void) { double Frequency[18]; system ("PAUSE"); return(0); } double Frequency (void) { int count;
I am using two threads and i want to take value of a function from one thread and use it in other. I am not good at the concepts of threads. Here is the following code:
Code: void ThreadA(void const *argument){ uint32_t status = I2S002_FAIL;
status = I2S002_Config(&I2S002_Handle0, &I2SConfig_U0C1_A); if (status != DAVEApp_SUCCESS) {
[Code] ....
So, i want to use the return value of temp_buffer from ThreadB into Thread C and want to put this value to TXBuf in ThreadA...
why the function is not returning the integer 1 or 0 ... We have two arrays A and B, each of 10 integers. Write a function that tests if every element of array A is equal to its corresponding element in array B. The function is to return true (1) if all elements are equal and false (0) if at least one element is not equal.*/
#include <stdio.h> #include <iostream> #include <time.h> using namespace std; int TEST (int arrayA[], int arrayB[], int j); int main() { srand (time(NULL));
Polygon* create_square(const Vector2d& position, const RGB& colour, const std::string name) { // Polygon, Vector2D, RPG and Vertex2d are structs with public data members only Polygon *temp = new Polygon; temp->name = name; temp->colour = colour; temp->position = position; temp->vertices = new Vertex2d; return temp; }
I have a function, which has to return some int data. In that function there are multiple return statements. There is also possibility that function may return in some cases. Will this result in undefined behavior???
I am writing a function to take two vectors and put them end to end in a third vector. I'm new to working with vectors, and I cannot figure out why my append function is not returning vector C. I had the function print out vector C within it to make sure the logic in the function wasn't the problem, and it worked perfectly. My code is as follows:
#include <iostream> #include <vector> using namespace std; //append function to put vector b after vector a in vector c vector <int> append(vector <int> a, vector <int> B)/>/>/> { vector <int> c;
[code]....
and my output is as follows:
Vector A contains: 10 18 123 172 Vector B contains: 283 117 17
The two vectors back to back are:
Obviously, the third vector is not returning from the function to main properly, but why.
I'm having trouble returning a char array by a function, here's the code. The problem is the 'reverse' function, the purpose of the function is to send two char arrays, 'newline' containing the char array, reverse it and place it in the 'rev' char array then output it back in main, however the output remains blank so I assume there must be something wrong with the reverse function.
Code: #include <stdio.h> #define MAXLINE 10 int fgetline(char line[], int maxline); void copy(char to[], char from[]); void reverse(char forw[], char rev[], int arrsize);
How to use a function twice to calculate two different variables. How to have a function compute the city tax, then it uses the function a second time to compute the county tax.
My program compiles, and runs fine, however it only outputs the city tax calculation. It seems it never attempts to calculate the county tax.
One thing: All of the directives I used is what we are limited to, no more, no less. He requires a set format and will dock points of you use anything but those directives and void main().
I know how to pass a 2-D array to a function. The prototype for that is void f(int (*p)[2]) assuming the array is of integers and there are 2 columns in it.
However, if I wanted the same function to return a pointer to a 2-D array, what would be the prototype?