34 Discussion / Question Topics

Remove Filter
Member Avatar for
Member Avatar for can-mohan

Hi All, In below code i am getting ouput of process (based on name) memory and cpu utilization % using command "ps -C gnome-terminal -o %cpu,%mem | tail -n +2" .Here gnome-terminal is name of process for that i am printing these values. Now i want to implement the same …

0
149
Member Avatar for can-mohan

Hi All, I have to implement string class and write a program to perform string manipulation in Mystring class. input: "he is going to school" output Case 1: (n=1) He school to going is Case 2: (n=2) He is school to going Case 3:(n=5) No changes Case 4 n<=0 school …

Member Avatar for JamesCherrill
0
475
Member Avatar for can-mohan

Hi, Guys i just wanted to know whether set store elements in specific order or it contains unordered elements only. As per c++ specification http://www.cplusplus.com/reference/set/set/?kw=set Sets are containers that store unique elements following a specific order. As per my knowledge they are not ordered in the sense that you can't …

Member Avatar for JamesCherrill
0
299
Member Avatar for can-mohan

Hi, In below function i am not able to figure out why predicate function cmp_str can't be used with for_each algoritham while using this algoritham with map. #include <iostream> #include <map> #include <utility> using namespace std; struct cmp_str { bool operator()(string a, string b) { return a.compare(b)<0; } }; int …

Member Avatar for can-mohan
0
3K
Member Avatar for nathan.pavlovsky

Hello all! I am trying to take a string that has mixed uppercase and lowercase chars and then convert it to lowercase. I am doing the following line of C++ code: transform(theReadMessage.begin(),theReadMessage.end(),theReadMessage.begin(),theReadMessage.end(),::tolower); //theReadMessage is a string to convert to lowercase and my C++ xCode debugger gives me this message `Too …

Member Avatar for nathan.pavlovsky
0
717
Member Avatar for pdk123

Hi, I have the following map : listOfPolicyRuleInfo CPCRF::m_mlistOfCliConfiguredPolicyRules; where typedef map<string, PolicyRuleInfo> listOfPolicyRuleInfo; where PolicyRuleInfo is a struct struct PolicyRuleInfo{ BearerQoSInfo stBearerQoS; TFTInfo stTFTInfo; PolicyRuleInfo(){}; PolicyRuleInfo( BearerQoSInfo const& qos, TFTInfo const& tft) : stBearerQoS(qos), stTFTInfo(tft) { } }; listOfPolicyRuleInfo m_mlistOfCliConfiguredPolicyRules = boost::assign::map_list_of("PolicyRule_Fred", PolicyRuleInfo( BearerQoSInfo(9), TFTInfo())) ("PolicyRule_Voice_C", PolicyRuleInfo( BearerQoSInfo(5), TFTInfo())) …

Member Avatar for DeanMSands3
0
497
Member Avatar for Mayukh_1

**Okay this is my first post and I am quite excited that how it will be recieved by the community. I have a long experience in C++ programming but never been a part of any community hence I believe that as a tyro, my mistakes will be ignored.** This post …

Member Avatar for NathanOliver
0
307
Member Avatar for pdk123

Hello, I have a basic c++ STL question. I have an octet array class (legacy). Now lets say the octet array has the following contents: array[0]=00 array[1]=01 array[2]=30 array[3]=01 array[4]=114 The key we need to generate from the above array should match ["00130-1-114"] Whats the best way to get this …

Member Avatar for L7Sqr
0
253
Member Avatar for kungle

If I (have to) use C/C++, I'm mostly working on time-critical or real-time applications. Examples are OpenGL texture Streaming (Example: Streaming Satalite Data on planet surface in realtime: https://www.youtube.com/watch?v=ws2ra5MvDi4) or real-time PSM audio maonpulation (Example: Automatic tuning a guitar to a C64= SID tremolo: http://www.yousry.de/audio-example-real-time-tune-detection-tuning-auto-tuning/). During development I'm using "**-O0 …

Member Avatar for Maritimo
0
587
Member Avatar for nathan.pavlovsky

Hello programmers! After covering the basics of STL, I decided to complete the following assignment: `Write a function template palindrome that takes a vector parameter and returns true or false according to whether the vector does or does not read the same forward a backward.` So, for example, a vector …

Member Avatar for NathanOliver
0
1K
Member Avatar for can-mohan

Hi, I am getting below error after executing below code. **Error**: In function `main': undefined reference to `Point2D::Point2D(int, int)' class Point2D { public: Point2D(int,int); int getX(); int getY(); void setX(int); void setY(int); double getScalarValue(); bool operator< (const Point2D &right) const { return x < right.x; } protected: int x; int …

Member Avatar for Moschops
0
259
Member Avatar for pdk123

Hello , I have map of the following type: typedef map < int, vectorofInts > , Now the map has finite size. Each user when he registers, he will be allocated a key. Lets say the map size is 4. U1 will be allocated in K1. next U2 on K2, …

Member Avatar for pdk123
0
250
Member Avatar for pdk123

Hi, In the legacy implementation, there is a Queue (which stored the PDUs) which need to be retransmitted. The queue has been implementated as stl map (c++). So the last element in the Queue may not be the largest SN, as per transmit window. Is there any easy way to …

Member Avatar for rubberman
0
188
Member Avatar for skyyadav

How to sort vector<int> v{3,2,7,6,5,8,1,2,3,4,5}; in decreasing order using function object. I did using lambda expression sort(v.begin(),v.end(),[](int a , int b){return a > b;}); But How we do using fn object

Member Avatar for mike_2000_17
0
270
Member Avatar for skyyadav

int main() { map<string,size_t> count; string word; while(cin >> word) count[word]++; --------(1) for(auto it=count.begin();it!=count.end();++it) cout << it->first << ": "<< it ->second <<endl; I donot understand the code particularly the line (1) Could anyone can explainÉ

Member Avatar for techofunda
0
210
Member Avatar for skyyadav

implement a generic fn mapf with prototype template<class Sequence c , class UnaryFunction) Sequence mapf(Sequence c , UnaryFunction f) for ex if c is a seq containing the seq (3,2,7,6,8) and f is the fn that returns twice it integer agument. then container returned by mafc(c,f) is a list containing …

Member Avatar for mike_2000_17
0
304
Member Avatar for skyyadav

given int a[]= {3,2,7,6,8,1,4,5} vector<int> v(a,a+8) use the stl copy algorithm to display the last 5 integers in the vector to cout with each integer on a seperate line. copy takes three argument. third argument is output container. In this case it is v.but v already have 8 elemenst. How …

Member Avatar for mike_2000_17
0
191
Member Avatar for Suzie999

Hi Does anyone know if there is an equivilent of std::stoi (string to Int) for use with wstring that I am missing? Seems a bit odd that it would be ommitted from the library, but I cannot find anything. Thank you for reading.

Member Avatar for Suzie999
0
209
Member Avatar for Xorlium

Hello! I'm writing some mathematical iterators over some big classes that I don't want to store in memory at all, but I still want to be able to iterate through them. As an example (but I have a few of these), think of a class `Combinations({0,1,2...7}, 3)`, which means I …

Member Avatar for Xorlium
1
313
Member Avatar for k_arjun

When I try to find all subsets of a set using the following code, the iterator vit in the inner for loop of the getPowerSet function misses out on one element certain times. Can anyone tell me why? #include<iostream> #include<vector> #include<set> using namespace std; vector< set<char> > getPowerSet(const set<char> &given); …

Member Avatar for k_arjun
0
239
Member Avatar for Labdabeta

I have been having this problem since I started using stl containers awhile ago. Basically, when I debug them with the default Code::Blocks MinGW debugger I find that it gives far too much irrelevant information such as iterators and other 'behind-the-scenes' stuff. I can make it better by telling it …

Member Avatar for Labdabeta
0
296
Member Avatar for abhimanipal

Hi everybody, Please excuse the noob question as I am new to STL in C++. I am trying to write a very basic program which uses iota. However my compiler is complaining that iota does not exist in algorithm. Some other forums suggested including <backward/algo.h> as iota could have been …

Member Avatar for mike_2000_17
0
2K
Member Avatar for abhimanipal

Hi Folks, Here is another noob question. I am trying to write a simple predicate for the find_if function in STL. Here is my code #include<iostream> #include<vector> #include<algorithm> #include<iterator> using namespace std; class InRange{ const int& low; const int& high; public: InRange(const int& l, const int& h): low(l), high(h){} bool …

Member Avatar for Saith
0
396
Member Avatar for abhimanipal

Hello everybody, I am trying to teach my stl and after writing some basic programs I have hit a road block. I have an iterator which I am trying to pass to a function template Here is my function template template <class T> void display(typename vector<T>::iterator start, typename vector<T>::iterator end){ …

Member Avatar for abhimanipal
0
172
Member Avatar for sergent

I decided to learn C++ STL and I was exprimenting with STL containers. I saw this example [here](http://www.cplusplus.com/reference/stl/vector/insert/): // inserting into a vector #include <iostream> #include <vector> using namespace std; int main () { vector<int> myvector (3,100); vector<int>::iterator it; it = myvector.begin(); it = myvector.insert ( it , 200 ); …

Member Avatar for sergent
0
337
Member Avatar for Ahmed2

hello there, I'm trying to sort a list according to the "length" paramter in ascending order, which represents the third coloumn. List elements are read from a csv file contains 9 coloumns, I only push 6 coloumns in "futurelist" which is the information i'm intersted in. //input csv data [CODE] …

0
102
Member Avatar for Ahmed2

Hello there, submissiontime length finishtime remainingtime 1031 17:11 574.1025391 MB 1050 17:30 1 1326 22:06 536.0175781 MB 1343 22:23 2 2721 45:21:00 608.1279297 MB 2741 45:41:00 3 32 0:32 575.8115234 MB 51 0:51 4 1161 19:21 652.6259766 MB 1182 19:42 5 937 15:37 288.7597656 MB 946 15:46 6 3087 51:27:00 …

Member Avatar for Ahmed2
0
314
Member Avatar for kodemaaster

I am declaring a structure as this [CODE]typedef struct Request { deque<int> roomsList ; }Request;[/CODE] Then , in some other function I get a segmentation fault in the highlighted line : [CODE] int initRoomsList(Request *R) { int roomSatisfying ; char roomName[20] ; int roomNum, capacity,wb,proj, lcd, sound, aud, vid , …

Member Avatar for raptr_dflo
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 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

The End.