How do I return a specific value from a function in order for me to cout it in my int main?
In this case i have solved for a value sigma1 in my function but i want to use the value of sigma1 in my int main also and in other places so how would i do that?
so I wrote this code in class today and I'm almost done but I need to come up with some sort of equation to add up all the total values. The problem is I am reading data off a txt file so it's all being read as one thing. I don't know how to get each specific value and add them all together. This is my code so far.
I end up multiplying the amount by the price to get the total value as shown in the code above. Now I just don't know how to add the total value of each item to get the total overall value. Also I haven't used invTotal because I want that to be the overall total.
Basically I am creating a game and I need the ai to look for specific buttons. At the moment this is the code I have, and what it does is it makes the ai look for any random button that has't already been clicked.
Code:
private Button look_for_spaces() { Console.WriteLine("Looking for spaces"); Button b = null; foreach (Control c in Controls) { b = c as Button; // performs a cast
[Code] .....
Now what I'm trying to do is make the ai go through 4 searches in steps instead of looking for any button. I want it first to look for buttons 1, 2 and 3, if there's a space in any then it will be clicked but if all of them are already clicked it will look for spaces in buttons 4, 5 and 6 and so on if that makes sense. But i'm not too sure how I would do it.
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.
I want to get the value of "Skateboard" on file. So I need to read 9 lines. On the 9th line, the gets() loop will stop. But, what if I only want to get the value of "Skateboard" as integer (87) and not a string? Also, is it possible to scan the value of Skateboard if it's located on a different (or unknown) line?
im having trouble with a function im writing. Its supposed to find the minimum value in an array and return the location of that value heres what i have so far :
int findLowest (int numb []) { // findLow will hold the subscript of the lowest value in the array int findLow = numb[0]; int x; for (x = 0; x < 5; x++){ if (numb[x] < findLow) findLow = x; } return findLow; }
I want to replace what is in a specific sector with value inside a buffer(dummy value). This code will read what is inside a specific sector. To make sure it works it display what is inside the sector and it displays the chosen dummy value. (the two cout's in main)
What I want to do is to replace the dummy value with what is inside the specific sector. So if the dummy value is '0', I want to replace what is in sector 285 with '0'.
I'm trying to open a text file with the name "text.txt", for the purpose of only displaying in the console an specific part of the text file. For example, if I got "This is a test [TEXT] This is the message that should display [/TEXT] this is the end of the file", I want only "This is the message that should display" to be the output, the thing is that I can't imagine anyway of doing that. what I should do?
Code: #include <iostream> #include <vector> using namespace std;
class A{
[Code]....
I read somewhere, that we can imagine the reference as a pointer to the vector. So, my question is:
Let's assume that instance of class A, named a, was created with new. We call a.getV() to foo and then we call the destructor of a. foo is safe? Is the copy constructor of std::vector called?
What the code below is not doing is returning a value for item to my variables (item1, item2, etc..) I'm not sure how I can make a function prototype that will ask for input and basically recycle after going through the program to a new value for each item. I also need to input individual tax for each item. I will also post it in this message:
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 am currently doing a bodyfat calculator for a course in school.I'm having a problem getting an output returned from my while loop, which determines the user's gender by user input.My function (outside of main) is currently:
Code:
char gendercheck(gender){ while (true) { gender = _getch(); if (gender == 'M' || gender == 'm') { system("cls"); printf("Your selected gender is male."); break ;
[code]....
My failed tries include "return gender" and "return genderpicked" statements in both the if-functions and the loop itself, which I have deleted since that didn't work. My goal is to get a character stored in gender, so that I can use the information of the user's gender in my main function from this point and onwards.
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...
In the code below. I believe I am returning the memory location of the value I am looking for. How can get the value?
main.cpp
int choice = 0; PlayerMenu *newPM = new PlayerMenu; File *file = new File; // Menu for loading, creating or exiting the game choice = newPM->menuChoices();
PlayerMenu.cpp
[Code] ....
I am not sure how to deference the value so I can get at the value instead of the memory location.
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));
I am working on this program below. The problem I am having is trying to return totalDays to the main. In the numOfDays() function there is a for loop that adds the totalDays (totalDays = totalDays + days). I have just been getting errors in returning the correct amount of totalDays to the main from the numOfDays function.
#include <iostream> using namespace std; int numOfEmployees(); int numOfDays(int); int main() { int totalDays = 0;
When returning an object by reference, only the address of the returned-object is returned, and that way we spare pushing a large object into the stack, and also spare time of pushing and popping large object to/from stack.
But what happens when the object that receiving the returned-object, is not a reference, but a 'regular' object?
How is the content of the returned object copied into the receiving object?
See for example in main, wid vs rwid. (I know in the case the returned-object is just one variable, there's no need to return it by reference, but its for simplifying the code).
class Rectangle { public: Rectangle(int w=0, int h=0);