177 Topics

Member Avatar for
Member Avatar for toneranger

I have some stock market price data organized as follows in a structure: struct PriceInfo { string Date; unsigned int Time; double Open; double High; double Low; double Close; unsigned int Volume; }; This struct organizes price data per interval of date and interval of time, where time is measured …

Member Avatar for toneranger
0
849
Member Avatar for George_91

I've this quicksort code, and it compiles. The thing is, I don't know how to give random values (integers) to the vector. The program should ask for the vector's size and then create the x random integers so it can apply the quiksort method. [CODE]#include "stdafx.h" #include <iostream> #include <vector> …

Member Avatar for George_91
0
2K
Member Avatar for arunkumars

Hi, I would like to get few tutorials on rendering and vector data in WPF. The requirement I have right now is to get the vector data (path) of a text that has been rendered on a canvas. I can however get the vector data of the text using the …

0
111
Member Avatar for wazzer225

Hello just curious, I know that i'm supposed to use new in c++ but decided to experiemnt with malloc. Can you explain to me why the following code crashes and what is the reason. I was under the impression that the size of vector is fixed as it just stores …

Member Avatar for Stefano Mtangoo
0
3K
Member Avatar for Godservant1

Someone gave me this challenge See how large a type is by storing powers of 2 in this list of types: float, double, long double. To determine if a number will fit, start with 1.0, double it, then divide by 2 to see if you get the previous number. For …

Member Avatar for nyquist
0
143
Member Avatar for imcgrath1

Hi I come from Python background and learning C++. In one of my programs, I need to have one key with multiple values and both being strings. for e.g. [CODE] "str1" ---> "value of str1" "str2" ---> "value of str2" "str1" ---> "value of str1 1" "str1" ---> "value of …

Member Avatar for mike_2000_17
0
3K
Member Avatar for Coffee_Table

I am trying to run what i thought was a pretty basic program to solve a problem concerning strings (besides the point). It turns out that my algorithm works properly but i am stuck on a detail; the following segment of code is the problem: [CODE] int cases; string line; …

Member Avatar for Coffee_Table
0
585
Member Avatar for goluman

[CODE] IpPairVec matches; blah blah other definitions for (unsigned int i = 0; i < matches.size(); ++i) { drawPoint(img1,matches[i].first); drawPoint(img2,matches[i].second); const int & w = img1->width; //.........etc etc etc } std::cout<< "Matches: " << matches.size(); //This returns a number after every iteration which is continuous. //I am able to redirect …

Member Avatar for Narue
0
177
Member Avatar for harryhaaren

Hey all, (Skip down till "Question:" if you're in a rush) Context: I'm coding on an audio application which involves storing buffers of audio. I'm currently using a [ICODE]std::vector<float>[/ICODE], as a member of an [ICODE]AudioBuffer[/ICODE] class. These [ICODE]AudioBuffer[/ICODE] instances are held in another class [ICODE]ResourceHolder[/ICODE]. In the "process" callback (where …

Member Avatar for harryhaaren
0
607
Member Avatar for mridontknow

[CODE]#include <iostream> #include <algorithm> #include <vector> #include <string> #include <ctime> #include <cstdlib> using namespace std; vector<string> function1(vector<string>v) { for(int i=0;i<4;i++) {cin>>v[i];} return v; } int main () {vector<string>v; vector<string>guess; vector<string>guess=function1(vector<string>v); cout<<"size:"<<guess.size()<<endl; cout<<"contents:"; for (int i=0; i<guess.size(); i++) {cout<<guess[i]<<"";} cout<<endl; return 0; }[/CODE] i need to build vector<string>guess(4) in function function1 …

Member Avatar for sfuo
0
128
Member Avatar for mridontknow

i got difficulty here, i dont know how to create a random vector consist of 4 strings. using vector. [CODE]int main () { string red,yellow,blue,green; }[/CODE] i want to create random vector for those four colors. please help me.. -im a beginner for c++

Member Avatar for mrnutty
0
2K
Member Avatar for IndianaRonaldo

[CODE]void SubGen(char* s) { //rearrange s ... for(int i=0;i<strlen(s);i++) { for(int j=i+1;j<strlen(s);j++) { if(s[i]==s[j]) { char temp=s[i+1]; s[i+1]=s[j]; s[j]=temp; } } } //s arranged.... Sub[0][0].push_back(s[0]); for(int i=1;i<strlen(s);i++) { if(s[i]==s[i-1]) { vector<string> temp; for(int j=i-1;j<Sub.size();j++) { for(int p=0;p<Sub[j].size();p++) { temp.push_back(Sub[j][p]); } } for(int j=0;j<temp.size();j++) { temp[j].push_back(s[i]); } Sub.push_back(temp); } else { …

Member Avatar for IndianaRonaldo
0
213
Member Avatar for IndianaRonaldo

[CODE] vector<vector <vector<char>>> Sub; Sub[0][0].push_back(s[0]);Sub[0][0].push_back('\0'); Sub[0][1].push_back('\0'); [/CODE] I have the above code and it says "vector subscript insaccessible" for the assignments.What could the reason? Thanks in advance, Prasanna

Member Avatar for IndianaRonaldo
0
170
Member Avatar for brynjar

Hi, I'm pretty new to C++ but have a lot of experience in Python. In python its pretty straight forward to make functions that both take arrays/vectors as input and return arrays/vectors. My thought here is to make a function to calculate the gravitational force between to bodies with mass …

Member Avatar for lcordero
0
224
Member Avatar for u8sand

I programmed this vector class to support different types and different amount of dimensions. (class T,int D) D is the dimension. I don't use templates much and I'm running into an error, my constructors aren't working. Here is my class [CODE]#include <stdio.h> #include <stdarg.h> template <class T,int D> class Vector …

Member Avatar for mike_2000_17
0
245
Member Avatar for CPT

[code="C++"] class item { string name; string identifier; public: item( string name,string id):{this->name=name;this->identifier=id;} friend ostream& operator<<(ostream&, const item&); friend istream& operator>>(istream&, item&); }; ostream& operator<<(ostream& out, const item& temp) { out<<item.name<<" "<<item.identifier<<endl; return out; } istream& operator>>(istream& in, Cmessage& temp) { getline(in,item.name);//in case sring has space char getline(in,item.identifier); return in; …

Member Avatar for mike_2000_17
0
173
Member Avatar for K0ns3rv

A little program I made to try and remeber C++, first program I've written in C++ in about a year. Tested and working under windows 7 64 bit, run via command line. If you have any improvements or ideas please leave a comment. Cheers K0ns3rv

Member Avatar for mrnutty
1
315
Member Avatar for nocloud

I have a the following snippet of code [CODE]string const& symbol::at(int index) const { assert(index<symbol_data.vector::size()); return symbol_data.vector::at(index); }[/CODE] This does not compile successfully, instead, I get complaints about [CODE]error: ‘template<class _Tp, class _Alloc> class std::vector’ used without template parameters[/CODE] Now, I think this has something to do with the fact …

Member Avatar for mrnutty
0
324
Member Avatar for nocloud

I am experiencing unexpected performance degradation when using vectors with classes. I have a csv_File class that reads in a csv file and stores the contents in a 2D vector. There's a member function that allows access, e.g. [CODE] csv_File file("file.csv"); file.access(2,2);[/CODE] To access the 2,2 element. Then, I have …

Member Avatar for mike_2000_17
0
184
Member Avatar for luislupe

I have several vectors of int elements. Now I want to create a vector of vectors, but I don't want to copy the vectors to the new one. If possible, I'd like to pass them by reference. Please consider: [code=c++] #include <iostream> #include <vector> using namespace std; int main () …

Member Avatar for ravenous
0
201
Member Avatar for andylbh

The code below is what I have done up so far. I'm currently trying to complete one of the 4 classes I have, so the codes are incomplete and made to work at it's current stage. Q1. I need to have 3 different sorting criteria: 1.Sort by X (asc/desc) 2.Sort …

Member Avatar for mike_2000_17
0
781
Member Avatar for khsheehan

So I always seem to encounter this error. I usually find some odd hackish fix for it but this time I'm having too much trouble. I'm basically trying to make a program which corrects words the user types in (similar to that of any modern phone). The function I'm posting …

Member Avatar for arkoenig
0
151
Member Avatar for John Linux

Hi, If i have a vector in MATLAB v; [CODE]v = [1 2][/CODE] How can i push a value say '7' to the vector. ie. v = 1 2 7 I am currently doing it in a loop: count = 0 ie. for 1 to 10 count = count + …

Member Avatar for Thisisnotanid
0
374
Member Avatar for cousinoer5

This program keeps track of a hardware store inventory. It's very barebones, all it needs to do is put the information into a vector of pointers to a struct, allow the user to sell items, and print the report. I have printing down no problem, but selling is where I …

Member Avatar for Chilton
0
174
Member Avatar for Gnomy

I've been searching this for a little while now and I'm absolutely unable to figure out what the problem is. This is the code I'm having the issue with: [CODE] std::vector<std::string> TexName; TexName.push_back("mega.png"); [/CODE] and I get... error: 'TexName' does not name a type I've included both vector and string …

Member Avatar for template<>
0
539
Member Avatar for tikoti

Hi! I am looking for something to compact the clear and push_back in one line... [CODE] std::vector<int> v(3,100); v.clear(); v.push_back(4); [/CODE] I have thought that vector::swap may be usefull for this task but still figuring out how. Any sugestion or idea? Thank you in advance!

Member Avatar for tikoti
0
166
Member Avatar for Theisonews

i want to create a program that will have an arraycalled array1[] of 30 sets of 3 one digit numbers i.e 804, 450,430 etc) i will have 13 vector containersor arrays defined with a series of 3 one digit numbers. i want the program to find any series of numbers …

Member Avatar for Lerner
0
121
Member Avatar for jnewing

so what i'm trying to get my head around it say i have a vector of vectors containing some unsigned chars and i want to copy a certain vector to another vector as follows. [CODE] std::vector< std::vector< unsigned char > > foo; std::vector < unsigned char > bar; for (int …

Member Avatar for L7Sqr
0
170
Member Avatar for Climber Ty

So this is my final project for my class. The idea is to use my RationalNum class (which is complete and works fine... I just didn't attach the .cpp since it was only the driver) and use it to add, sub, & multi polynomials (RationalNum being the coefficients i.e. 1/4x^3 …

Member Avatar for Climber Ty
0
472
Member Avatar for TheSassyDragon

Trying to understand two dimensional vector and was wondering if anyone could help me out on a sorting code for this so that it numbers 0-9 people, gets x number with each of them and then outputs the person (number) ate x pancakes - But in descending or ascending order. …

Member Avatar for TheSassyDragon
0
153

The End.