Im trying to write a program that reads in strings and decides if the 1st one is repeated. I cant figure out how to store the first string into a variable, and compare that variable to the rest of the inputted strings.
Code:
#include <strings.h> #include <stdio.h> int main () { //Declared variables int i; }
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 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
How do you store a variable in memory so that it isn't changed when the program closes? I don't have any experience with this and am just wondering how it is possible. I am creating a program and want it to store your preferences and scores. In a simple program, everything is just reset and I don't want this for my program. How do I store a variable so that it stays the same, but can be changed even when the program is turned off?
Is it even possible to store the 100th Fibonacci number (beginning with the numbers 1 and 1) into a variable? I know the number is pretty huge, and wondered if there is a data type to hold a number that big.
I would like to store the entire content of a file in a single c-string variable or in a standard string class variable. Is there a function that will do this for me? I am familiar with functions that get one character or one line at a time but I don't think I've encountered a function that gets the entire file. Does this function keep or disregard the end-of-line character? If no such function exists, I would write my own function to create and return such a variable.
I've been trying to store the inital size of a list in an int variable, so I can access it later in case I modify the list size. For example, I did the following:
std::list<AType *> myList; myList.push_back(anATypeobject); int initListSize = myList.size(); //initial list size myList.push_back(anotherATypeobject); myList.push_back(yetanotherATypeobject); while(myList.size > initListSize) myList.pop_back();
What this is supposed to do is to get an initial size of a list, and then be able to return to that initial size. However, when I try to do it in my code, initListSize always change if myList.size() changes. Is there a way to change that?
5502 5202.3 1523 2536.1 1254 1256.2 17846 8956.2 and so on
left one is time and right one is pressure, I need to show the time value as it is but i need to use the pressure value to calculate air speed. I don't know how to use the strings to pick up the list properly. I did the calculation formula for the air speed but i can't pick the pressure value up from the text file. here's what i did:
#include <iostream> #include <fstream> #include <string> using namespace std;
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:
I need to average integer measuring samples and store this variable, so that it can`t be changed.
I need to get the initial pressure reading from my bmp085 pressure sensor, an integer value between 0 and 10000 and store the initial value after program start, so I can compare the later readings to determine whether pressure went down or up. The value to store should also be integer, rounding errors don`t matter.
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 created a class (let call it X) which contains the structure to store the data from my data base. Them I have a class (call Y) which will contain a list for each row in my data base. Third, I have a class with thousands variables (Z). What I am trying to do is to take the list of objects (Y) that contains the data to initialize Z. What I want to now if I can do something like that.
Imaging that one of my rows contain the following data: Type Nameofvariable etc... "static const double; MNFAIL ; 0; 0; 0,25"
In my list I have a node with contain this data
I want to use the field Nameofvariable to initialize the variable called MNFAIL contained in my class Z.
I want to store values permanently in a variable. The same variable should be able to be edited and saved by user, and whatever it is I need the value of the variable from the last time I modified it, like a database. database because i need this to set my connection string of the database.
This does not allow me to initialize _listRef as something like NULL when it is not applicable.Also, i must change all my constructors and its child class to include an initialization of _listRef!!
What is the alternative? Is pointer the nearest? which of the following should be used?
Code: const QList<QSharedPointer<Data>> * _listRef; or const QList<QSharedPointer<Data>> *const _listRef; or const QSharedPointer<QList<QSharedPointer<Data>>> _listRef; ????
I want to store the address of a customer (with spaces) in a char variable (say cadd). First I tried to use "cin", as we know it reads until it sees any whitespace. So it reads only first word before a white space. So, I used "getline()" function, it will work. But when I used it, It did'nt wait for the I/P (it skipped it).
Now I would like to extract the data inside these comment tags and insert into excel sheet. Need to extract the comments in the xml tags shown in the able format? For example I want the value inside the <Autor> tag.
I'm building a simple little program for minecraft to reduce the repetitiveness, I'm using getpixel, it's slow, but i only need to grab about 6-12 pixels.
but the problem is, I can get the pixel data if I capture from the entire desktop display, but as soon as I tell it to grab from the active window (wich goes MUCH faster) it doesn't return any colour value's.
I'd rather not have to use getDIBits or program in java or anything since I want to keep it fairly kiss, and if it can't be done, then.. ah well, I'll just grab from the entire desktop, speed isn't to much of an issue, but it'll be a pain to keep the window at the same place.
Code: #include <Windows.h> #include <iostream> using namespace std; // vvv Ignore this, it's just used for retrieving the handle of a window without giving the full window name vvvv struct results {
I am trying to write a loop that will iterate through a char array in C and pull the IP addresses and test them to see if they respond. My ultimate goal is to have the first one that responds returned in the function, but the loop is not running correctly. It will run through right the first time, but then will start over again.
Code output: Contents of srList b4 loop: 1.1.1.1 Server List: 1.1.1.1 result is "1.1.1.1" Hitting else loop Contents of srList in else: 2.2.2.2 result is "2.2.2.2" result is "2.2.2.2" Contents of srList b4 loop: 1.1.1.1 Server List: 1.1.1.1 result is "1.1.1.1" Hitting else loop Contents of srList in else: (null)
I'm extremely rusty at C but is this the best way to store an input string into a char*?
Code: int length = 100; //initial size Code: char * name = malloc(length * sizeof(char)); //allocate mem for 100 chars int count = 0; //to keep track of how many chars have been used char c; // to store the current char
while((c = getchar()) != ' '){ //keep reading until a newline if(count >= length)
name = realloc(name, (length += 10) * sizeof(char)); //add room for 10 more chars name[count++] = c }
I am having trouble with parsing out string value into a 2D vector. Suppose i have the string "attack at dawn " consisting of 15 characters, i will like to store it into a 2D vector with 5 rows and 3 columns and the result is as follow.
Vector[0][0] = "a" Vector[0][1] = "t" Vector[0][2] = "t" Vector[1][0] = "a" Vector[1][1] = "c"