C :: Using Variable Names When Calling MC PIN High Or Low
Feb 9, 2013
I haven't tried to run my program yet, but maybe I will save some trouble if I ask this question first.I am using MC PIC16F690, and I could make a pin high or low by writing RCx = 1 or 0, where x is the pin in the C port. However, I want to use the counter variable from a for() loop as the pin number. Will RC(variablename) = 1 work, or is there another syntax?
View 2 Replies
ADVERTISEMENT
Oct 17, 2013
I'm trying to find a way to call a variable checkbox.
i.e.
for (i = 10; i < 20; i++) {
Checkbox[i]->Caption = Some Database Information
};
Note: Checkboxes are all called Checkbox10 ~ Checkbox19
View 3 Replies
View Related
Oct 15, 2014
I have been playing about with Vertices and Colors and have ended up with this:
template < std::size_t SIZE, typename T >
struct Pack
{
[Code].....
Is there anyway to make an alias for Pack's data field? Something that would allow me to write:
Color3f my_color;
my_color.red = 0.1f;
View 3 Replies
View Related
May 1, 2012
I am looking at some C++ code that has many variables that start with underscores. Why? What's the point? I know in Python its a way to keep them private, but I don't understand why we would do that in C++ when we can just make something private.
View 14 Replies
View Related
Dec 6, 2012
I am trying to write a program that would convert numbers of base 10, decimal numbers, to binary or hexidecimal numbers, base 2 and base 16. I want the program to run a loop through the various numbers input and store each number converted to the new type in a separate variable with the same basic name but different last letters/digits to differentiate between them and add them to the total.
Basically, I'm saying that i have the user input a number and letters. Let's say 15, d, b. So they want to convert 15 of decimal type to binary.
The program would then take the variable used to hold that number, and the other to variables to decide what function to perform on the number.
Then I will already have a variable initialized for the 3 possible conversions (binaryKey[], decimalKey[], hexideciKey[])
Then I want it to convert it and store the number at different places in the array to form the final number. Although, there is no way to predict what number the user will input, so there is no way of knowing initially where the converted place-value will need to be placed in the array.
I was wondering if there was a way to have the program run a loop where as the progression continues, it appends a number to the end of a universal name for the variables and then adds them together in the correct order creating the sequence that means that number.
In simpler terms:
Input a number: 15
Input type of base: d
Input converted type: b
Program then continually divides the number by 2, storing the remainder in a new variable
Such as: for(int i=1, i < (str(number).len), i++){
when i = 1, you would get
int number1;
[Code] ....
and so on. Is there a way to do this???
View 5 Replies
View Related
Jul 2, 2014
I am trying to call a function through a variable
The error
|error: no match for 'operator=' (operand types are 'std::string {aka std::basic_string<char>}' and 'void')|
|warning: statement has no effect [-Wunused-value]|
||=== Build failed: 1 error(s), 1 warning(s) (0 minute(s), 0 second(s)) ===|
#include <iostream>
#include <fstream>
[Code].....
View 3 Replies
View Related
Dec 19, 2013
Expected output: 20
But what I got is: 22
Why. While calling sub function it should take the global variable am I right
insert Code:
#include <iostream>
using namespace std;
int a=0;
void sub()
[Code] ....
View 3 Replies
View Related
Feb 10, 2013
i have a vector of stores. i would like to delete the specified choice(store) from the list. Here is what i have but my erase statement is wrong and wont compile.
void Store::deleteSpecifiedStoreFromList(string choice) {
for (int i = 0; i < this->stores.size(); i++) {
if(this->stores[i].getStoreNames() == choice) {
this->stores.erase( std::remove_if( this->stores.begin(), this->stores.end(), choice ), this->stores.end() );
}
}
}
View 4 Replies
View Related
Mar 28, 2015
I've made a game and a dialogbox to show up asking to enter a nickname.
The problem is After entering the nickname, it won't show on the highscore list below (textbox)
Where can the problem be? Below is my code:
private void btnPlay_Click(object sender, EventArgs e) {
if (txtName.Text != "") {
Settings.Name = txtName.Text.ToString();
[Code] .....
View 5 Replies
View Related
Sep 21, 2013
I suspect that C++11 would make it possible to declare high rank vectors such as Code: int N = 15; // chosen arbitrary rank vector<vector<vector<...<vector<double>>>>..> vec; // N layers of nested vectors Is there a way to declare such a vector of rank N (given a fixed integer rank N)?
Heuristically I would like to write the declaration like this: Code:
vector<double> A;
vector<A> vec[0];
for(int i=1; i<N; i++)
{
vector<vec[i-1]> vec[i];
} Is there a way to use the new variadic templates to make this work?
View 9 Replies
View Related
Feb 6, 2015
The bottom three functions do not work. Nor are the finished to the extent. I do not know how the data members are being accessed and is only giving me the last output. The overall goal of this program is to output the highest grade with student name and age, lowest grade with student name and age, and the average of all grades. The file is given and is commented out for you to see what the file looks like.
// Header Files
#include <iostream>
#include <fstream>
using namespace std;
// Global Constants
const int STD_STR_LEN = 10;
[Code] .....
View 5 Replies
View Related
Jul 15, 2014
I have taken a keen interest in writing trading programs. I have some Python background, a little C# but no C++.
The example below was provided in a book on HFT and I would love to see how the results look. I was hoping that I would just compile it and away you go!
That didn't happen. To start with the author listed this as a function, so I converted it to a main program. Still having issues with my path and where to see the output. Here it is..
Code
void HFT_AvellanedaStoikov() {
FILE* fin, *fout;
double lambda_a, lambda_b, d_lambda_a, d_lambda_b;
int hh = 0, mm = 0, ss, nb = 0, na = 0, prevnb = 0, prevna = 0, prevm = 0;
double bid, ask, prevbid = 0, prevask = 0;
char * p1, *p2, buffer[1024], fname[512];
[Code] .....
Here is some data:
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
.... and so on ....
View 3 Replies
View Related
Jun 1, 2013
Write a program that allows a user to enter high scores of a game, keeping tracking of the name of the user and the score. Add the ability to show the highest score for each user, all scores for a particular user, all scores from all users, and the list of users.
This is the program I am trying to write, however I am having difficulty storing the users name and high score, I know I need to store an array for the score but getting confused because of the structure. (By the way I have to use structures as it is a problem from the structures chapter of the ebook I am doing). Below is my code so far. .
Code:
#include <iostream>
#include <string>
using namespace std;
struct highScore
{
string user;
int score;
int highestScore;
int allScores;
[Code]...
View 9 Replies
View Related
Jan 12, 2013
One of my programs I recently created, needs higher precision then what doubles can provide. So I am wondering how I install a library like this [URL] .... I don't quite understand exactly how to install them. Im using visual studio 2012 ultimate right now!
View 3 Replies
View Related
Jun 26, 2014
On a project I'm working on, I need to update many QLabels very quickly. Each label needs to be updated at about 20 to 50 hertz and there can be over 50 labels at any given time. The problem I'm having is after running the program for about a minute, the labels freeze and the whole program crashes about 10 seconds later. If I comment out the setText() and setNum() calls and reroute the outputs to the console, it runs fine and never crashes. Why does calling SetText() and setNum() so quickly cause the program to crash and how can I prevent this?
View 5 Replies
View Related
Dec 23, 2014
I basically have a listbox that has postcode areas i.e : AE,CW,GU etc etc.
The user selects this and then a postback occurs - an sql statement is builts and a database query operation is performed and the results are returned to a datatable called tempdata.
So far so good. I then need to loop through this datatable and copy the records to my main viewstate datatable which is the datasource for google maps api.
DataTable tempstore = GetData(querystring, "");
//check tempstore has rows otherwise add defaultcust as default otherwise map will be blank
if (tempstore.Rows.Count == 0)
{
[Code].....
So my main datatable can grow and grow as users add more postcodes. However when it gets to around 500 rows or so I get a huge memory spike only on postback and then it settles back down.
My ram usage goes from 2gb to 3gb and if even more postcodes is selected it maxes the memory and crashes my pc.
If I remove the:
dtpc.Importrow(row);
the memory spike goes completely, obviously because the main datatable has no rows. I thought you only run into memory issues when you have thousands of rows?
View 1 Replies
View Related
Jan 21, 2013
How to create a symbol table for an assembly language and high level language in c++?
View 1 Replies
View Related
Aug 30, 2014
I was investigating for the first time how to generate prime numbers with a considerably high upper limit, around 10^6 or so. I read about sieve's algorithm and tried to implement it using c#, as I had previously brute forced the generation. In Sieve's algorithm, instead of marking the values that were not prime I simply eliminated them, but I don't think that would make any difference. The issue is that my implementation of sieve's algorithm must be wrong, as when I establish the limit as 10^5 I get the following output:
Brute force:
Computation time: 00:00:00.0643539
Sieve's algorithm:
Computation time: 00:00:20:6934223
I have already checked that their generation of primes is correct, but I do not know why one is significantly slower than the other. Here is my code.
using System;
using System.Collections.Generic;
using System.Linq;
[Code].....
View 5 Replies
View Related
Mar 20, 2015
how to manually control the temperature of High Power Leds using PID controller. I have two GUIs,one reads the temperature from the Led while the second is used to ON/OFF the Leds and at the same time controls the Led brightness using slider control.The GUI that reads the temperature has a PID controller application on it.The output from this controller is what i want to use to increase or decrease the Led brightness which invariable changes the Led temperature.How to go about using this PID controller to control the Led brightness is what i have not been able to grasp well.The slider on the GUI is scaled from 0% to 100%.My thinking is that the output from the controller should be in percentage which will make me to adjust the slider accordingly.My question is that will this type of arrangment produce an output that will efficiently control the Led brightness. how to accomplish that. Attached to this post is a modified code of a tutorial on PID controller which i found on the net. a tutorial on how to develop a graph. i wish to display the Setpoint,Process value and the output value on a graph.
View 2 Replies
View Related
Feb 13, 2013
I am writing a program which handles the CAN messages Received from BUS.My code is taking almost 60% of CPU usage.
View 14 Replies
View Related
Jul 11, 2014
I am making a multiple quiz program. So everything is working fine, except for the part where i'm trying to add a highscore for each user which is being stored in a binary file. I have added a sample of the program containing the error. This isn't the actual program, which is very long.
class user { //The collection of all info pertaining to the users
char user_id[50];
public:
int hscore1;
user() {
strcpy(user_id,"NULL");
hscore=0;
[Code] ....
View 1 Replies
View Related
May 10, 2013
I would like to convert a float or double variable into unsigned char variable and back.
float number_float = 23.453f;
unsigned char* number_char = (unsigned char*)malloc(sizeof(float));
number_char = reinterpret_cast<unsigned char*> (&number_float);
float* number_float_0 = reinterpret_cast<float*>(&number_char);
I am not getting the same value back.. why?
View 2 Replies
View Related
May 1, 2013
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.
View 11 Replies
View Related
Mar 2, 2013
This problem is best explained by looking at its output below. I stored 15 different values but when retrieved some are wrong.
#include <iostream>
using namespace std;
class A {
public:
int ** pointer;
[Code] ....
I need to store and retrieve the 15 different values correctly. How to solve this? The main thing is, I need to store the pointer in class A objects.
View 6 Replies
View Related
Sep 8, 2013
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.)"
View 5 Replies
View Related
Feb 9, 2013
I am trying to create an array of file names such that when I want to open one of the files, who's name is given in the array, I can call that element of the array. My code for making the array is the following,
Code:
char file_name[40];
char *file_locations[N]; // array of N names (*)
for(ii=0; ii<=N-1; ii++){ // printing the names of all the files P1_8mag_1.txt - P1_8mag_N.txt
sprintf(file_name, "P1_8mag_%i.txt", ii+1);
[Code]....
The problem with this is that in the first step: all elements of the array "file_locations" are the name of the last file in the loop (in this case "P1_8mag_N.txt")What is wrong with this?
View 12 Replies
View Related