825 Posted Topics

Member Avatar for miskeen

You could populate a vector with the values you deem valid and [icode]std::random_shuffle[/icode] that vector. At that point you could just iterate over the shuffled vector to get random values.

Member Avatar for vijayan121
0
227
Member Avatar for Sonia11

Templates allow you to condense the example you gave into a more generic approach. The fact that you are both filling and reversing your vectors within you reverse* calls prevents you from doing this directly. Idealy, what you want is to combine the duplicated code between the two versions you …

Member Avatar for L7Sqr
0
172
Member Avatar for shima.khanehzar
Member Avatar for qasimhasnain

The de facto set of tools for this is [url=http://dinosaur.compilertools.net/]Lex/Yacc[/url] (Flex/Bison) What have you written your lexical analyzer in? Generally, this is tightly coupled with the parser so integrating yours with an existing tool may prove to be difficult.

Member Avatar for L7Sqr
0
156
Member Avatar for atticusr5

Search for ASCII escape sequences. You can use these to control how text appears on a terminal.

Member Avatar for L7Sqr
0
60
Member Avatar for Protoroll

If you are dealing with ethernet frames there are structures available to manage the contents. For instance, on a linux machine you might look in /usr/include/netinet/. One of the files in there is tcp.h which provides a structure that maps to the data you are trying to read. Also, there …

Member Avatar for L7Sqr
0
127
Member Avatar for cableguy31

strace will do a lot of work for you in terms of beautifying it's output. What you see there is the full details of a struct timeval (indicated by the [icode]{}[/icode] surrounding the values. A [icode]struct timeval[/icode] has two data members: seconds, and microseconds since the epoch.

Member Avatar for template<>
0
374
Member Avatar for 07knev

[QUOTE=07knev;1546110]Hi I want to boot the Laptop / Desktop via network boot CD and get connected to shared folders. Shared folder contain Ghost image ( WinXP and Win7). Please let me know how can i create a network boot CD Thanks Knev[/QUOTE] Have you looked into something like [url=http://en.wikipedia.org/wiki/Preboot_Execution_Environment]PXE[/url] booting?

Member Avatar for 07knev
0
255
Member Avatar for gcardonav

Try changing [icode]cin >> filter, season;[/icode] to [icode]cin >> filter >> season;[/icode]

Member Avatar for gcardonav
0
145
Member Avatar for Abhishek Joshi

Probably ancillary to your stated problem, but what do you do when x is 0 in the following [icode](sent[x-1] == ' ') [/icode]? You are probably looking for [icode]((x == 0) || (sent[x-1] == ' '))[/icode] You probably also want to look at line 64. Perhaps [icode]x < 120[/icode] would …

Member Avatar for L7Sqr
0
108
Member Avatar for luislupe

I'd suggest you not try and do the visualization from within your code unless that is the focus of your efforts (which it seems is not the case). Since there are plenty of software that exist for this purpose already (gnuplot, R, matlab, etc.) I believe it would be better …

Member Avatar for L7Sqr
0
332
Member Avatar for Labdabeta

How about [url=http://www.cplusplus.com/reference/stl/bitset/]std::bitset[/url] or [url=http://www.boost.org/doc/libs/1_36_0/libs/dynamic_bitset/dynamic_bitset.html]boost::dynamic_bitset[/url]?

Member Avatar for Labdabeta
0
202
Member Avatar for geekme

[QUOTE=geekme;1544195]As far as description goes, I need to implement a network router and graphics do not have to be 3D.Simple and easy to learn graphics is needed to show nodes of graph and simulation of packets across a link. KIndly help.[/QUOTE] Any reason you can't use [url=http://www.isi.edu/nsnam/nam/]nam[/url] (with [url=http://www.isi.edu/nsnam/ns/]ns-2[/url])?

Member Avatar for Kanoisa
0
212
Member Avatar for GhostMonkey

I'd suggest you keep a vector of previous entries and provide an interface to access that data (or use vector iterators to do it). For instance [icode]vector::push_back[/icode] will allow you to add to the end of the vector and you can use an iterator to cycle backwards through the set …

Member Avatar for L7Sqr
0
1K
Member Avatar for resell4

By the time your program is in binary form the location is known and it is an absolute jump to address. The only time this would matter (if at all) is the compilation stage. I'd argue that unless all time is dominated by compilation time you shouldn't need to worry …

Member Avatar for sergent
0
90
Member Avatar for afnan92

Maintain a game control loop that iterates through the movable components and updates them each 'tick' of the clock.

Member Avatar for WaltP
0
84
Member Avatar for cableguy31

Timing can be done using [icode]gettimeofday[/icode]. If you want to connect to the outside network you need to provide an address to connect to (localhost is 127.0.0.1, you dont want that). I'd suggest trying to use a connection to google at port 80 to download the search page.

Member Avatar for cableguy31
0
324
Member Avatar for sha11e

What is your project? You posted a video to a game, but I'd claim that ncurses is seldom used for games except as a thought experiment or for a particular genera. More understanding of your problem would help provide an appropriate resource or example.

Member Avatar for L7Sqr
0
80
Member Avatar for daviddoria

I'm not sure I understand the problem. In the example you gave all you need to do to solve for any missing parameter is to sum the negative value of the values provided. It's the same equation, regardless of the missing parameter - for any number of parameters. Are you …

Member Avatar for mrnutty
0
742
Member Avatar for Marrodriguez

It would be helpful to see both the code and error messages about that code to expand. Does [icode]image.h[/icode] exist? Are you including it from the proper path? Do you need to link to a library to be able to use the definitions in that header?

Member Avatar for L7Sqr
0
91
Member Avatar for kumaresen

Please use code tags when posting code. Anytime you see an error related to 'identifier not found' that usually indicates that you've forgotten to include a header file that declares the function/variable you wish to use. In this case it might be [icode]#include <conio.h>[/icode] that you are missing (although I'm …

Member Avatar for Fbody
0
287
Member Avatar for kumaresen

Please use code tags when posting code. To answer your question: Change [icode]char letter;[/icode] to [icode]char letter = 'F';[/icode] That will initialize the letter variable to some known value and ensure that non-random data is not used if nothing else is assigned. In your case, if total is less than …

Member Avatar for JasonHippy
0
228
Member Avatar for SWEngineer

[QUOTE=SWEngineer;1535972] [code] A::A( int iNum ) : m_iNumber( iNum ), m_bFlag(true) { } [/code] the same as: [code] A::A( int iNum ) { m_iNumber = iNum; m_bFlag = true; } [/code] [/QUOTE] Yes and No. For the simple case, the two are functionally equivalent. However, there are special cases where …

Member Avatar for L7Sqr
0
174
Member Avatar for narlapavan

Is thsi a C++ specific question? You might want to do this via a command line as the tools are already available for you. If you [i]must[/i] do this from within another program, I'd suggest you [icode]fork/exec[/icode] a child process and execute the ping command. Use the return value of …

Member Avatar for L7Sqr
0
149
Member Avatar for waqarafridi

There are no [i]strings[/i] in C. There are character arrays. The [icode]str[/icode] in your above example is an array and can be used like one ([icode]str[4][/icode] for instance). If you'd like to convert that to a non-const array you will need to create storage and copy the contents. For example:[code] …

Member Avatar for waqarafridi
0
5K
Member Avatar for mahendra maurya

What information about the process do you want? Is the process programmed to respond to you or do you expect to query this information without the knowledge of the program istelf?

Member Avatar for L7Sqr
0
140
Member Avatar for mahendra maurya

[QUOTE=mahendra maurya;1533551]Network statics means TCP State or UDP State...[/QUOTE] TCP and UDP state apply to connections, not to the machine. You can use built-in facilities to get an overview of all connections on a local machine but the programs differ from platform to platform ([icode]netstat[/icode] is available on *nix flavors). …

Member Avatar for L7Sqr
0
144
Member Avatar for jnewing

[QUOTE=jnewing;1533965]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. ... How can i go about doing this? [/QUOTE] Do you want to have a [i]copy[/i] …

Member Avatar for L7Sqr
0
173
Member Avatar for Prisms

In addition to the methods described above I find that [i]reading[/i] other code is terribly beneficial. Find a medium sized project on sourceforge or github and just get familiar with the way other people write code: what's good, what's not. The more exposure you have the more base you will …

Member Avatar for L7Sqr
0
144
Member Avatar for vedro-compota

File descriptors are just integers. The management of them is hidden from you, the user, but when they are provided it seems that open will select the lowest integer not currently associated with an open file for your process. In general, stdin, stdout, stderr are referenced internally using file descriptors …

Member Avatar for vedro-compota
0
185
Member Avatar for sha11e

In addition to what Fbody mentions, including an entire namespace can hide subtle errors in code (especially for beginners). Consider the following:[code]#include <iostream> #include <algorithm> using namespace std; int main () { int x = 5, y = 3; cout << "Before swap: " << x << " " << …

Member Avatar for Fbody
0
173
Member Avatar for bleedsgreen33

I'd suggest something more along the lines of[code]int DSum2 (int v) { if (v < 10) return v; return DSum2 (DSum (v, 0)); }[/code]It's important, though, that you understand [i]why[/i]. Work through the solution (yours and this one) and record each step. The beginning of this one would look like:[code] …

Member Avatar for Fbody
0
139
Member Avatar for rockerjhr

[QUOTE=pratik_garg;1525005] But you have forget one thing to compare node number in both the list. [/QUOTE] It really depends on what a 'set' constitutes here. Remember, in its truest form, a set has no duplicates so converting an array (or list) to a set can change its size. For instance[code]List: …

Member Avatar for L7Sqr
0
873
Member Avatar for Labdabeta

No. In order to do what you want you need to 'wrap' the type in a class and provide operators through that interface.

Member Avatar for L7Sqr
0
179
Member Avatar for Shruti4444

[QUOTE=Shruti4444;1526030] I tried doing it with vectors..[/QUOTE] The point is that we would like to see what you've done so far so we can help you. The fact that you have not finished this indicates that you have specific errors. If you describe these errors with some relevant code snippets …

Member Avatar for mike_2000_17
0
2K
Member Avatar for ichigo_cool

[code]class Unit { int x_; public: Unit(int x) : x_(x) {} }; class Soldier : public Unit { int soldier_specific_stuff; public: Soldier(int x, int y) : Unit(x), soldier_specific_stuff(y) {} Soldier(int y) : Unit(default_unit_stuff), soldier_specific_stuff(y) {} };[/code] You can pass items to the constructor of the base class in the initializer …

Member Avatar for L7Sqr
0
94
Member Avatar for Talguy

I'd try and stay away from allowing the mutual dependency between the two processes. If either of the two of them could fail (another question is [i]why[/i] is it ok for them to fail) then you have a bad race condition. It might not fit what you want to do …

Member Avatar for L7Sqr
0
78
Member Avatar for iamthesgt

[icode]enum -> int[/icode] is a one-way street. You can not convert [icode]int -> enum[/icode] directly. What you can do is redefine [code]void setMode(VideoOutPutMode mode)[/code]as[code]void setMode(int mode)[/code] [b][u]HOWEVER[/u][/b]... The former version (the one with the enum) provides direct control over the values that can be passed into that function. You do …

Member Avatar for iamthesgt
0
3K
Member Avatar for shakisparki

It is the size (in bytes) of the memory you want to request. In general, you determine this with the [icode]sizeof[/icode] operator as with your first example.

Member Avatar for Narue
0
113
Member Avatar for Kadence

Any chance you can wrap the library headers in a separate namespace? Something like:[code]// in foo.hh class Foo {}; // in foo.cc namespace hidden { #include "foo.hh" } int main () { Foo foo1; // Fail do to namespace wrap hidden::Foo foo2; // works as you would expect // ... …

Member Avatar for Kadence
0
287
Member Avatar for shanki himanshu

There is [i][b]very[/b][/i] little context here with which to operate, but my guess is that you need to clear the attributes you set on your screen after the output before trying anything else.

Member Avatar for L7Sqr
0
59
Member Avatar for benjamin.sh

[icode]printf[/icode] and [icode]scanf[/icode] take [roughly] the same set of format characters. Read the manual pages on either of the two and look for 'hex'. [url=http://www.manpagez.com/man/3/scanf/]Here[/url] is a starting point.

Member Avatar for L7Sqr
0
1K
Member Avatar for SIFA

By default, operations such as [icode]scanf[/icode] split on whitespace. All that remains is to be able to not overflow buffers and to recognize when the stream has reached an invalid (or empty) state. What exactly are you having trouble with?

Member Avatar for L7Sqr
0
131
Member Avatar for sergent

You can create locally-scoped variables within a specific case statement similar to[code] switch (x) { case 1: { /* Things created here are local to the case 1 statement */ } // ... }[/code] However, you should always include the { } and, as you have found out, you can …

Member Avatar for WhiZTiM
0
193
Member Avatar for jmalbornoz

A singleton is a design pattern. It is a way to describe a class that get instantiated only once but can be shared by many callers. Here is an example:[code] class Timer { int x; Timer () : x(0) {} // Private static Timer * only_copy; public: static Timer * …

Member Avatar for jmalbornoz
0
3K
Member Avatar for math.man

The C language supports mathematical operations. For instance[code]#include <stdio.h> int main () { int x = 1 + 2 + 3; printf ("%d\n", x); return 0; }[/code] Will output [icode]6[/icode]. I dont see an apparent pattern in your numbers so I'm not entirely sure what the [icode]...[/icode] is to stand …

Member Avatar for abhimanipal
0
86
Member Avatar for moroccanplaya

[icode]recv[/icode]'s second argument is a buffer, [b]not[/b] a [icode]FILE*[/icode]. You likely need something like:[code]FILE * fout = fopen (...); unsigned char * buff[255] = {0}; n = recv (newsockfd, buff, 255, 0); // ... fprintf (fout, "%s", buff); // ...[/code]

Member Avatar for abhimanipal
0
175
Member Avatar for frenzra

You dont [i]put things in cin[/i]. cin is a stream operator; you use it to extract elements from a stream. As an aside, the language of your post will (in the general case) cause less people to respond seriously. 'Q' is not a suitable substitution for 'Question'; juz is not …

Member Avatar for frenzra
0
140
Member Avatar for Incubator

I found it helpful when I was learning recursive behavior to write the function out at each step with indentation. For instance, given the following:[code] int fun (int n) { if (n < 1) return 1; else return 1 + fun (n - 1); }[/code] I would write it out …

Member Avatar for rubberman
0
118
Member Avatar for CPT

[icode]vector<X*> Ccontainer;[/icode] is a vector of pointers. You call the [icode]>>[/icode] operator with a pointer as an argument ([icode]a.Ccontainer[i][/icode]) but define it as taking a reference ([icode]operator>>(istream& in,X& x)[/icode]). Thats the best I can tell without you describing the actual error you are experiencing.

Member Avatar for L7Sqr
0
96

The End.