Visual C++ :: Range And Incrementation
Feb 6, 2015
So there is suppose to be a constant that shows the total number of values to be shown in this range. The user enters two values, lets say userMin is -2 and userMax is 2, it's suppose to add 0.2 to -2 and so on until it reaches 2. It starts doing that up until it reaches -1.0, then it goes to -0.9, -0.7.... etc, It also goes beyond 2.
Code:
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
cout << fixed << setprecision(1);
float userMin;
float userMax;
[Code] .....
View 1 Replies
ADVERTISEMENT
Sep 25, 2014
I am attempting to write a simple program and compile it onto a 3pi robot. My problem lies with my array, i need the array to increment by one every time through and whenever i run the code the print out reads "ROOM 0" every time.
#include <pololu/3pi.h> /* allow use of 3pi robot functions */
#include <avr/pgmspace.h> /* allow use of program space */
#include <stdio.h> /* for printf() */
#define NUM_ROOMS 11 /* the number of study rooms */
/* function prototype for battery check */
void bat_check( void );
[code].....
View 4 Replies
View Related
Oct 5, 2014
I'm having problems with progress bar when using a big number in set range. For numbers below 50000 it works very well but for big numbers like 100.000 it doesn't work, it makes 2-3 rounds of animation
Code:
int number= 50000; // 50k works well but if i put 100k it won't work (it will animate 2-3 rounds instead of complete one)
progressbar1.SetRange(0, number);
progressbar1.SetStep(1);
for (int i = 0; i < number; ++i) {
listcontrol1.InsertItem(i, _T("whatever"));
progressbar1.StepIt();
}
What's wrong with the code ?
View 5 Replies
View Related
Mar 4, 2015
Using Excel Automation in Visual Studio 2010 C++, how do I define a name? As a user of Excel, you can enter a name that then can be used in formulas to refer to a range of cells. The range changes as the user inserts columns or rows. My program has worked with various versions of Excel dating back to the early 2000's.
I have a bunch of classes derived from COleDispatchDriver: CXLApplication, CXLRange, CXLWorkbook, CXLWorkbooks, and CXLWorksheet that have many functions, but I have no documentation... How to define a named range using functions of these classes (probably CXLRange)?
View 6 Replies
View Related
Nov 3, 2014
I have an assignment where i have to prompt the user to enter the name of a file then open that file and read names of students and what level they are at university
eg : John Wilkins, sophomore
Dan Robertson, junior
etc..
i did the code and it compiles perfectly, but when i input the name of the file it gives me error: string subscript out of range.
here's the code:
Code:
#include <iostream>
#include <cstring>
#include <string>
#include<ctime>
#include <fstream>
using namespace std;
int * read_file(string filename)
[code]...
View 2 Replies
View Related
Mar 24, 2014
In my app the user can select the pages to print by typing in a start and an end page. I think this is the standard dialog.
How can I give the user the possibility to select e.g. page "1,2,6-9" like in Word?
View 4 Replies
View Related
Dec 4, 2012
Write a function named generateLotteryNumbers. The function is passed an int array of size 5. The function should generate 5 different lottery numbers in the range 1 to 50 inclusive and place the numbers in the array. The declaration is as follows:
void generateLotteryNumbers (int lotteryNumbers []);
Note that no data is passed in to the function. The array is used to return the function results. Thus the parameter is an OUT parameter. Do not display the result. Return the result.
Do not seed the random number generator inside the function. If you seed the random number generator inside the function and the function is called many times in the same second, your function will return the same results each time it is called.
I know how to generate the numbers in the specified range but I do not know how to test for duplicates. Here is the code I have so far:
Code:
//This program will test the "generateLotteryNumbers" function
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
void generateLotteryNumbers (int lotteryNumbers[]);
[Code] ....
When I try to compile this, my compiler tells me that lines 41 and 46 require an array or pointer type.
View 8 Replies
View Related
Apr 24, 2013
I have a ULONGLONG variable uDate which express the number of dates starting from 0001-01-01, up to 9999-12-31. Now I want to convert it into a string like this
"yyyy-mm-dd"
However, the COleDateTime can only express the date from 100 to 9999, smaller than what I need. So are there any third-party classes or libraries that can express this. Or make the conversion from uDate to CString?
View 1 Replies
View Related
Feb 10, 2015
I want to define a range of exit codes in my application. These codes will be used as a return value of ExitInstance function. I want to know the exit codes availables (values not used for example by windows to inform about an other error). When I force to crash my application, I get some different error codes: 8148, 10176.
What is the no available range exit codes?
Is this the ranges code unavailable?
[URL]
View 1 Replies
View Related
Nov 9, 2014
My program behaves weird... I wanted to generate 10 random numbers from 1 to 100 each of them bigger than previous, using the while loop and function that returns a random number in specified range.
When I run the program, I get numbers much bigger than 100, even negative number, and numbers are same every time I run the program.
Code:
#include <ctime>#include <cstdlib>
#include <iostream>
using namespace std;
int range(int low, int high);
[Code] .....
View 2 Replies
View Related
Nov 23, 2013
What the range of values and how to calculate them?
int Num = rand() % 350 + 13 / 10
View 2 Replies
View Related
Apr 14, 2013
i have to find 2 random values between a range, lets say from 0-3 i have to find all the possible combinations between this range like (0,0),(0,1)...etc But, it has to be RANDOM and the same combination cannot repeat it self(obviously).
View 8 Replies
View Related
Feb 17, 2013
I have an assignment where I have to use two for loops. I need to ask the user for any two numbers and be able to list all the numbers in between and their factors and state whether or not the number is prime or not.
View 2 Replies
View Related
Feb 16, 2014
In Particular:
N3337 wrote:86) this ensures that a top-level comma operator cannot be reinterpreted as a delimiter between init-declarators in the declaration of __range.
What in the world would be a valid example of when this might occur? (IE one that isn't blatantly misusing the quirks of the language).
This topic can also serve as a review topic on this presentation as well: [URL] .....
View 10 Replies
View Related
Nov 3, 2013
I've been debugging this program since yesterday and I continue to run into a string subscript error. I pasted the code in a pastebin (it's only 400 lines), to see why I'm getting this. The problem seems to come up during a debug assertion failure.
[URL] ....
View 5 Replies
View Related
Feb 26, 2014
whenever I try to use either <string> or any STL container. Everyone I saw so far, says that "using a .reserve(n)" before adding items to random positions is enough. However, each time I run the code, I still get the same error, unless I actually write the memory with some initial data, and only after access random positions.I am fully aware of the fact that the STL containers and <string> are dynamic data types and memory allocation is done dynamically. However, if I need to allocate all those memory slots before knowing how many I need, would lead me to the same memory complexity as using a char [] array (which is static -- size declaration at first).
how is it possible to keep the <string> dynamic, while being able to add elements on random positions (if possible). I know the strings have the ending char '', but there should still be something that would allow it to work. Okay, long story short, here is my example. I am trying to read from file rows of data. The first char on each row represents a normal char c. The rest of the row is a string which contains numbers (integers between 1 and 250) which represent the position at which the char c (read before) will have its location.
For example the input file:
#include <fstream>
#include <deque> // for later use
#include <string>
#include <sstream>
#include <algorithm> // for later use
[code].....
The program works perfectly, if instead of text.reserve(250); I use text.resize(250);. However, what is the difference between the two? I mean, why isn't reserve enough?
View 3 Replies
View Related
Aug 18, 2014
I keep getting this "Debug Assertion Failed" error that says:
expression: vector subscript out of range
I tried to make the loop the same as the vector size, but I'm still getting the same errors.
void Grid::output(ostream & out) {
vector<vector<int>> grid(4);
int rows, columns;
out << " 0 1 2 3 " << endl;
out << " +---------+" << endl;
for( rows=0; rows<grid.size(); ++rows ) // make each row
[code]....
View 3 Replies
View Related
Feb 23, 2015
In my program I have a range check setup in the class I call from main, but when I run it and put in a value > or < than the min/max it just calculates anyway. Where have I made a mistake?
Heres the Main
#include "box_class.h"
#include <iostream>
using namespace std;
int main() {
double length;
double width;
double height;
double volume;
[Code] ....
View 3 Replies
View Related
Jul 31, 2013
I'm making a simple game and I'm having trouble creating boundaries for the players movements. The map is a 2D vector. When I compare the vector with the players current position sometimes I get an error during run. When the error isn't occurring the behavior of the boundaries is bizarre. The error tells me that the vector is out of range.
Here is the where the map is created. It's within its own class constructor.
vector< vector<char> > map_parts;
map_parts.resize(25);
for ( int i = 0; i < 25; i++ )
{
[Code].....
View 1 Replies
View Related
Apr 10, 2013
I would like to try out a range based for loop. I am using gcc 4.6.3. According to the link below, gcc 4.6.3 should allow me to use a range based for loop.
[URL]
However when attempting to run the code below, my IDE (Eclipse) reports the following error:
"error: #error This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options:
int a[5] ={1,2,3,4,5};
for (int x : a) {
cout<<x;
}
If gcc 4.6.3 supports range based for loops why do I get this error?
View 1 Replies
View Related
Sep 23, 2013
Ok so I'm reading the Programming: Principles and Practice using C++ and Im stuck in Drill 4 part 5. It says:
Change the program so that it writes out the "numbers are almost equal" after writing out which is the larger and the smaller if the two numbers differ by less than 1.0/10000000
I'm using an If statement for it... I just need know what the formula is to check 2 numbers that were entered by person if they land within the range specified above. so then I can cout << "numbers are almost equal" << endl;
View 4 Replies
View Related
Jul 18, 2014
I'm trying to do some operator overloading, the function is supposed to add the values at index [i] of two vectors and place the result in the returning vector. The problem is I keep getting a vector out of range. This is the overloaded operator I'm working with (relatively new to these):
vector<float> operator+(const vector<float>& a, const vector<float>& b){
unsigned long size;
vector<float> temp;
if(a.size() >= b.size())
size = a.size();
[Code] .....
and then I would do something like this in the main:
vector<float> v, v1, v2;
v1.push_back(9.1);
...
v2.push_back(8);
...
v = v1 + v2;
but when I try to output the vector v I just get a vector out of range exception.
View 5 Replies
View Related
Aug 7, 2014
explain Range based for loops ?
View 7 Replies
View Related
Nov 15, 2014
I am writing a hotel reservation system, as such it has a date header that is responsible for date and time.
The issue is that sometimes when i execute the program a out of range exception is thrown, and other times it is not, even though the same information is being entered to test for consistency. Also the substr always has the first argument set to 0. So unless the string does not exist, which I have already confirmed it does, these errors are illogical.
View 5 Replies
View Related
Feb 6, 2014
I want to take a starting IP on a local network, and loop through to an ending IP on a local network, pinging all the IP addresses in between. For instance, ping all IP addresses between 192.168.1.1 - 192.168.1.255 (user enters desired starting IP and ending IP in text boxes).
I have the ping functionality working, and i can make it all work with lots of messy string parsing.. but it seems sloppy to me.
I have to split the strings (start and end IP) to get the last octet, then subtract to get the range of IPs. Then loop through, adding 1 to the last octet, and converting back to a string each time.
The C# Ping class can use either a string or an IPaddress for its Send method. If I use IPAddress, I just have to convert it from the text box it originates in, but the adding 1 to the last octet in the loop is a hassle.
Anyway, I guess the only question I have is, if you had to loop through a range of IP addresses, how would YOU do it?
public Job(string ipStartIn, string ipEndIn) {
long ip1 = Convert.ToInt64(ipStartIn);
long ip2 = Convert.ToInt64(ipEndIn);
IPStart = new IPAddress(ip1);
IPEnd = new IPAddress (ip2);
this.deviceAlive = false;
[Code] ....
View 14 Replies
View Related
Aug 10, 2013
#include <iostream> // std::cout
#include <algorithm> // std::next_permutation, std::sort
int main () {
int myints[] = {1,2,3};
std::sort (myints,myints+3);
std::cout << "The 3! possible permutations with 3 elements:
[Code] ....
this will result
123
132
213
231
312
321
The question is : If I want to get a permutation combination with range of N
What should i do?
if N = 2
result should be 12,13,21.....such and such
Eliminate the last digit is working for 3 combination but if its going to a bigger number it does not work ...
View 5 Replies
View Related