I'm having trouble trying to save a variable from an input of the user. Then use it when i start up another .exe.
If it makes any difference I am using dev c++. I'm using the input as an a or b so some one will put a for english or b for spanish. after that I want to use that info in another if statement of another .exe.
I am trying to create a global array with user-defined dimensions.the code is:
Code:
int matr_size() { int x = 0; printf("Please enter the number of nodes: "); scanf( "%d", &x); printf("There are %d nodes in this simulation.", x); getchar(); return x; }
[code]....
I read that an array cannot be defined by a variable in C so I assume that is the issue, but I'm not sure how else to do it. Previously the size was defined by #define NODES and it worked fine but I need this user input.
into an universal variable array.I just want to figure out a way to simply input the CSV file into a 2D variable array.The values in the array will be later use in functions that I'm trying to figure out but I can't do that until I store these values in the array. I think is just a matter of figuring out how to tell fscanf to ommit spaces and commas, but I don't know how. This is what I have done
I want to ask for a number as an input during runtime and then create an 2-dimensional array of size as specified by user. i.e. if the user inputs 3, the array should be of size 3X3, and likewise...
I am trying to make sure no floating point numbers can be input at any time in my roulette program. My code is too long to put in one post so I shall piece it out
#include <iostream> #include <iomanip> #include <random> #include <cstdlib> #include <ctime> using namespace std; // structure of arrays to pass to functions
I'm trying to increment the values in a vector, not the vector size, based on variable input. Basically I have a vector of size 10, and all of its values are initialized at zero. The program counts the frequency of numbers 0-9 in a four digit user input. This is what I have (I want it to work so badly but the compiler says that I'm using a pointer to a function used in arithmetic):
for (int i=0; i < num_slots; ++i) { ++guess_frequency[guess[i]]; }
I just want to know if you can increment values within a vector:
My program is designed to read input from the user and then store that input in a structure variable. Whenever i use the cin.getline() function, it comes up with a semantic issue. Here is the code:
Im building a banking system. in my create_account it asks for account address and phone number as well as other questions. When I go to my Show account info (balance inquiry) I notice its not getting the right address as well as phone number. its showing "garbage".
Code: /******************************************************************** * Vincent Dotts 09/29/2014 ch11.cpp * * This program serves as a customer banking system * *****************************HISTORY********************************* * WHO DATE Discription * ********************************************************************* * VD 09/30/2013 Created program * ********************************************************************/ #include<iostream> #include<fstream>
I am having trouble compiling my interface. I am trying to store a reference variable as a member variable of the interface object. Compiler says that the variable has not be initiated correctly.
LCD inherits from VisualInterface which is expecting a DisplayDriver object to be passed in (DisplayDriver is another interface, but thats not important).
I pass the displayDriver object in when LCD is instantiated in maininterfaces.zip
I was pasing it before as a pointer but was told that this could cause me problems with memory leaks and a reference was better, but now I cant seem to get it to compile.
I have to write a loop assigning a variable x to all positions of a string variable and I'm stuck. I don't have extensive experience with arrays and I'm also a bit confused about C-String. The problem is below.
"Given the following declaration and initialization of the string variable, write a loop to assign 'X' to all positions of this string variable, keeping the length the same.
char our_string[15] = "Hi there!";
(Please note this is a 'C-string', not C++ standard string.)"
I need to transform a local variable into a global variable so I can use it in one of my functions. I thought about passing the value as a parameter to this function but I can do this since the function is called inside the while loop and this variable counts how many times the while loop does (so the final value is outside the loop). Example to visualize better:
I want to store few different functions to a variable for different structs/classes and then call it later using that variable, is it possible? something like
struct item { int ID; int special; // for function };
item Key; Key.special = UseKey(KEY_KING);
// now when I want to call function "UseKey(KEY_KING)" I want to use "Key.special", like this
I've been experimenting with pointers and am getting the below error.
'error: cannot convert 'int**' to 'int*' in assignment'
I thought it was ok to assign a variable address to another variable. Line 18 is where I get the error.
I am trying to show the progression of memory as I increment it as I have done on line 17 and again, I don't know why I don't see a progression through memory locations when output to the console on line 20.
Here's the code: #include <iostream> #include <cstring> #include <cstdlib> using namespace std; int main() {
Any way to create a variable using a variable in the name? So E.g. if you wanted to create an int named nr(x), and x was 1, you would get an int variable named nr1? How would you do this?
I am trying to create a simple interface on console to allow to input some values to some variables. For ex:
int main() { double a = 1.5; double b = 2.5; double c = 3.5; string x;
[Code] ....
However, I want these three to display at the same time (now they display one by one), and in the console window I can move the cursor between input place of a, b and c with "arrow key" of keyboard.
Program is to add two fractions together like so..
This program adds fractions. ‘Y’ continues, any other key exits program =================================================== Enter numerator 1 ==> 1 Enter denominator 1 ==> 3 Enter numerator 2 ==> 1 Enter denominator 2 ==> 6 1 1 1 --- + --- = --- 3 6 2 ----------------------------------------------------- Continue? Y or N! ==> n
My question is that i need each input to be a number. if a character is entered i want it to output something like..
This program adds fractions. ‘Y’ continues, any other key exits program =================================================== Enter numerator 1 ==> 1 Enter denominator 1 ==> a You need to enter a number here. Press any key to continue.
and then clear the part where the letter was entered.
This program adds fractions. ‘Y’ continues, any other key exits program =================================================== Enter numerator 1 ==> 1 Enter denominator 1 ==>
So I have a class object that contains the private member variable spot and the public member function MoveLock. Within MoveLock, is a member variable called numbers that holds the place where a user is on a "lock knob". Now, what I'm trying to accomplish is that whenever the user turns the "knob" in the wrong direction, the position is updated with that current numbers so that the clicks needed to unlock the first state is also updated. But I get these errors:
Error E2096 C:Users...switchtest.cpp 34: Illegal structure operation in function main() Error E2294 C:Users...switchtest.cpp 39: Structure required on left side of . or .* in function main()
Ultimately, what I have in main() is a piece of what I'm going to implement in a class member function. I'm also thinking about moving the if else statements out of the for and creating a second one for the else portion.
Is it possible to increment a number but have it print out at a maximum value I assign if it reaches that number? For example, if I have 99 tickets total and only 5 of those tickets are still available, and a person requests 10, how can I give them the 5 available and make sure it doesn't go over the max (99)?
It would out put with the number of the tickets that the purchaser received:
RAFFLE TICKETS 0 - 29 given to PERSON 22 RAFFLE TICKETS 30 - 69 given to PERSON 209 RAFFLE TICKETS 70 - 95 given to PERSON 123 RAFFLE TICKETS 96 - 99 given to PERSON 211 NO RAFFLE TICKETS given to PERSON 27