177 Topics

Member Avatar for
Member Avatar for dancks

I don't really have an explanation and whoever thought that this new posting format was the way to go... idk what to say. I really don't like it. I can only post so much lines of code before something happens to the window and I can't scroll all the way …

Member Avatar for mike_2000_17
0
258
Member Avatar for JamesArhy

Hey Guys, I'm building an asteroids-like game and I'm needing to be able to apply the same operation too all of the different "aliens" on the screen. When I had two aliens on the screen I performed all of the functions manually but that is bad program design. I created …

Member Avatar for sfuo
0
795
Member Avatar for sampsont

I want to re-use a vector<short> over and over in a performance critical loop. I only need the vector **size** to be reset to zero at the end of the loop. I'm worried that the myVector.clear() takes time to actually clear all the memory. Also, does the myVector.reserve() survive the …

Member Avatar for sampsont
0
649
Member Avatar for merse

Wats wrong with this? std::vector<std::set<unsigned long> > surroundings; std::set<unsigned long> empty (); X = std::vector<std::set<unsigned long> > (N,empty); (where N is an ulong)

Member Avatar for mike_2000_17
0
169
Member Avatar for Lord_Migit

Hi there. I am having some trouble trying to figure out how to delete a pointer that is held in a vector. int main() { vector<Test*> iVector1; vector<Test*> iVector2; vector<Test*>* pVec1(&iVector1); vector<Test*>* pVec2(&iVector2); pVec1->push_back(new Test(11)); pVec1->push_back(new Test(12)); pVec2->push_back(new Test(23)); pVec2->push_back(new Test(24)); //delete iVector1.at(0); delete iVector1[0]; iVector1.at(0) = new Test(21); pVec1->at(1) …

Member Avatar for Lord_Migit
0
248
Member Avatar for Sunshine2011

#include <iostream> #include <vector> #include <iterator> using namespace std; class members { private: int Age; int Money; public: void setAge(int age) {Age=age;} void setMoney(int money) {Money=money;} int getAge()const {return Age;} int getMoney()const {return Money;} members(int age=0,int money=0): Age(age),Money(money) {} }; int main() { vector<members>v_members; for(size_t i=0,z=0;i<10;++i,++z) { if(z!=5) { v_members.push_back(members(50,70)); …

Member Avatar for Sunshine2011
0
219
Member Avatar for Lucaci Andrew

Hi. So my problem is that I can't save into a vector throughout a function, but I can save directly in the vector. /* * asd.cpp * asd.cpp is licensed under GNU GENERAL PUBLIC LICENSE * Created on: May 3, 2012 * Author: sin */ #include <iostream> #include <string> #include …

Member Avatar for Lucaci Andrew
0
167
Member Avatar for weeziefoo

I am a CS1 student and have had no issues until this point in the class really. I have been working on this for awhile now and cannot figure out how to get this to work! I am supposed to use this code and modify it to #1 - open …

Member Avatar for weeziefoo
0
589
Member Avatar for beginneronce

Hey guys, i am a beginner in c++ and i don't know what's wrong with my code. i'dont get any errors, but when i run the programme the following: "... Line: 251 Expression: vector iterators incompatible ..." I think there is a problem with "b.getmark()" and "b.getcoursename()" but i don't …

Member Avatar for beginneronce
0
711
Member Avatar for JOSheaIV

So first of all let me say I am pretty new to C++ and find it very difficult to learn (especially when compared to say C#) Anyway I am working on a program that requires the use of a 2D array or a similar container. After talking with a professor …

Member Avatar for JOSheaIV
0
3K
Member Avatar for ashboi

[CODE] vector<string> guess(4); cout << "Input a Guess(e.g red blue green yellow): "; cin >> guess[0] >> guess[1] >> guess[2] >> guess[3];[/CODE] this is part of my code to let the user input 4 different guesses, is there anyway I can limit the input by 4 so that if the …

Member Avatar for thines01
0
228
Member Avatar for mattiapdo

It doesn't run! Can you help me please? Devc++ compiles it, and also launch the exe file, but it stops after the second for cycle! Why? :D [CODE]#include <iostream> #include <string> using namespace std; int main() { int N,i,z; cout<<"Digitare il umero di caratteri che contengono il nome "; cin>>N; …

Member Avatar for LdaXy
0
168
Member Avatar for AleWin

I have a problem, I need to generate 16 random numbers (1-16) and insert them into 16 vector have tried using a for runs a check every time it fires a number but does not work .. [CODE]for ( i = 0; i <= 16; i++) { int[] v = …

Member Avatar for ddanbe
0
404
Member Avatar for Labdabeta

I have the following collision detection function that checks the collision between the line defined by lstart -> lend and the triangle defined by points a,b and c with a normal of nvec. I want to know if it will work and what to put into the missing part. (it …

0
75
Member Avatar for matt209

I'm new to using vectors and some may see this as a trivial problem. If you have any suggestion on how I can improve the program, I welcome your input. code(with problem): [CODE] #ifndef CMONOPOLY_HPP #define CMONOPOLY_HPP #include <vector> #include "head.hpp" namespace CMonopoly { class CMonopoly { public: ~CMonopoly(); void …

Member Avatar for matt209
0
629
Member Avatar for travelingt93

So i have a program i am writing,and i have come to problem. I want to be able to pass a set of three strings into a function, which should then take them and add them to a Vector. All good so far, now is where my problem develops, how …

Member Avatar for Ab000dy_85
0
205
Member Avatar for sota

Hi all, I ve been seeking a tutorial,article etc. about 2D cliext::vector . These are using <cliext/vector> library and cliext namespace. At once i need 2d vector decleration and its erase method to remove all rows which are full of zeros. Any help 'll be greatly appreciated.

Member Avatar for sota
0
369
Member Avatar for ahoysailor

Hello, I'm having a problem with finding and printing an element in a vector. I want to search my vector to see if an element starts with a sub-string, and if it does, I want to write the whole string to a file. The first part is done, I just …

Member Avatar for ahoysailor
0
294
Member Avatar for ahoysailor

Hi all, I've been trying to find part of a string in a vector. The problem being that I can only get it to work if I enter the entire string, but I need it so that I only search for the first part of the string in the vector. …

Member Avatar for Clinton Portis
0
175
Member Avatar for epicbeast9022

Hello everybody I [I]thought[/I] I understood inheritance but it turns out I don't. I am creating an SDL/OpenGL mini-GUI library. I have a master class, GUIComponent, with subclasses such as TextLabel under it. I have a vector called guiList that is initialized as [ICODE]std::vector<GUIUnit*> guiList[/ICODE] (it's extern'd and initialized elsewhere; …

Member Avatar for vijayan121
0
172
Member Avatar for Goshutu

Hi, i am doing a multiple-file project and i come across a difficult obstacles. I want your help, DaniWeb readers on this problem, which i find very strange: [CODE] #include "stdafx.h"//i have included vector header here #include "globals.h" #include "functions.h" using namespace std; #ifndef CPIECE #define CPIECE class CPiece { …

Member Avatar for Goshutu
0
330
Member Avatar for sangkun

Hi, The program I'm trying to make is to transcribe DNA to RNA and separate into codons. So far I was able to transcribe DNA to RNA and store it in string variable. Next part is to separate RNA strand into groups of 3 (codon) and store each group in …

Member Avatar for vijayan121
0
1K
Member Avatar for sangkun

I don't know a way to enter string into a vector. For example, there is string s = "augcuuaucaca" and I want to separate the string s into groups of 3 characters such as "aug", "cuu", "auc", "aca" and each group of characters would be string type. After that, I …

Member Avatar for Clinton Portis
0
179
Member Avatar for ahoysailor

Ok, so basically I have a text file that contains the following: Resource3 "Actuator" Resource10 "Insert Exhaust Valve" Resource1 "6, 10, 18, 1" Resource21 "Emergency Stop" Resource2 "Cool Down in Progress" etc. etc. I want to read the file line by line and store it in a vector (this is …

Member Avatar for mrnutty
0
173
Member Avatar for suiram

I have a text file which has data in it in the following format: string string char int double string Each field is separated by a tab character. The last string of every line contains multiple words. The file can have up to 50 lines (I am guessing if I …

Member Avatar for Clinton Portis
0
251
Member Avatar for lolwut25

I have an assignment where I have to write a program to prompt the user for a file name and location (it is a text file), once the user has entered that, a menu pops up and gives the user 4 options and asks which one they would like to …

Member Avatar for Lerner
0
2K
Member Avatar for optimumph

I'm trying to sort an array of numbers in ascending order and don't know whats wrong with my code (I'm completely new to vectors). I should first copy the input array (data) into an STL vector, then apply STL’s sorting algorithm to the vector, and finally copy the vector back …

Member Avatar for mzimmers
0
216
Member Avatar for thendrluca

Hello World! i wrote this code for fliping the array , but it doesn't work ... why can anyone say me ? what i did wrong? [B]array[/B] and [B]i,n[/B] variable are already global declared. [CODE] void exb(void) { int aux; for(i=0;i<(n-1)/2;i++) { aux=x[i]; x[i]=x[n-1-i]; x[n-1-i]=aux; } } [/CODE] thanks :)

Member Avatar for Adak
0
345
Member Avatar for George_91

I've a vector of size 'n', I need to do random couples with the n numbers (integers) and make a swap between them. Any ideas how? I had this idea [CODE] int low = 0; int temp; for (int high = n-1; i= low; high-- ) { temp = v[high]; …

Member Avatar for George_91
0
186
Member Avatar for TheNNS

This is a somewhat big project for me as I'm not very experienced in c++. The end goal is to read a text file, and read every word in the text file. Each time a new word is read, store it in a vector. If a word is repeated, keep …

Member Avatar for TheNNS
0
3K

The End.