825 Posted Topics

Member Avatar for zanje

The if/else construct is as follows:[code]if (condition) { // body of if } // ---- if (condition) { // body of if } else { // body of unconditional else } // ---- if (condition1) { // body of if } else if (condition2) { // body of else if …

Member Avatar for L7Sqr
0
111
Member Avatar for stereomatching

In C++ you allocate memory with [icode]new[/icode] and the initialization takes place in the constructor. You do not use [icode]malloc[/icode] and [icode]free[/icode] as the proper initialization and cleanup routines will not be invoked. If you are creating a non-dynamic structure then the constructor is invoked at object instantiation and you …

Member Avatar for mike_2000_17
0
2K
Member Avatar for jryans10

How would you suggest handling the following?[code]void Foo (int i) { if (i > 0) Bar (i - 1); } void Bar (int i) { if (i > 1) Foo (i - 1); }[/code]

Member Avatar for jryans10
0
128
Member Avatar for joy39

Why are you using pdcurses software to work through an ncurses tutorial? By definition there will be differences. Is there a reason you are not just using ncurses?

Member Avatar for L7Sqr
0
132
Member Avatar for ponnds

This is not a c++ question. However, the [url=http://tldp.yolinux.com/HOWTO/RPM-HOWTO.html]web[/url] has many resources.

Member Avatar for L7Sqr
0
73
Member Avatar for Knoxarama

You place a [icode]cout[/icode] statement to check for a value and then as for input to change that value again before using it. What is the reason of your call to [icode]getline[/icode]?

Member Avatar for Narue
0
294
Member Avatar for ahoysailor

[icode]find_if[/icode] returns an iterator. You should compare that to [icode]load.end ()[/icode] if you want to see if it succeeded. Then just use the iterator. [code]std::vector<std::string>::iterator vit = std::find_if(load.begin(), load.end(), StartsWith(thisString)); if (vit != load.end ()) { // do what you want with the iterator here }[/code]

Member Avatar for ahoysailor
0
297
Member Avatar for shibu2all

As [b]DJSAN10[/b] mentions this is undefined behavior. You will not get a clearer explanation than in the already mentioned thread: [url=http://www.daniweb.com/software-development/c/threads/405549/1732048#post1732048]Narue's comment[/url]

Member Avatar for Shardendu
0
137
Member Avatar for pororo11

The problem with your approach (and the one [b]subith86[/b] suggests) is that the environment variables you are setting are valid [i]only for the shell they are executed in[/i]. So when you call [icode]system[/icode] or [icode]putenv[/icode] you are respectively writing to a new shell that goes away after the [icode]system[/icode] call …

Member Avatar for L7Sqr
0
5K
Member Avatar for aamitrhce

Doing this in pure shell is a poor approach IMHO. My suggestion would be to use something such as Perl, Python or Ruby to parse the input. In Ruby you might use something like:[code=ruby]#!/usr/bin/env ruby require 'cgi' line = "2009-12-16 00:00:43,970 INFO [btpool0-12194://webmail.amit.com/Microsoft-Server-ActiveSync?Cmd=Ping&User=rahul%40kke.amit.com&DeviceId=androidc986729649&DeviceType=Android] [] sync - POST Microsoft-Server-ActiveSync?Cmd=Ping&User=ritesh%40kke.amit.com&DeviceId=androidc986729649&DeviceType=Android" if line …

Member Avatar for L7Sqr
0
340
Member Avatar for Despairy

Well, I don't know what [icode]BUFLEN[/icode] is but if you set your reads and writes to a specific size (i.e. [icode]sizeof(data_type)[/icode]) then you don't need to worry about how much is written and when since the [icode]SOCK_STREAM[/icode] guarantees proper order and the sizes are fixed. If you can not reliably …

Member Avatar for Despairy
0
173
Member Avatar for stereomatching

If you are looking for ease of use and understandability Ruby has a gem called [url=http://treetop.rubyforge.org/]Treetop[/url] that is pretty straightforward. You will have to be comfortable with Ruby, however. If you go the more traditional C/C++ route the de facto tools are lexx/yacc (or flex/bison). These are fairly heavyweight and …

Member Avatar for stereomatching
0
148
Member Avatar for ahoysailor

Instead of storing the entire line as a string, why not map the two values to key/value entries into a [icode]std::map[/icode]? Something along the lines of[code]while (file1.good ()) { file1 >> ids; file1.getline (val, VAL_SIZE); lut[key] = val; } // Then to look up a certain key... if (lut.find (ids_key) …

Member Avatar for Clinton Portis
0
181
Member Avatar for srinivas88

This depends on how you manage the reboot and sending of messages. For instance, using TCP, after a reboot you will need to reconnect do to the nature of the stream connection. If the server is OK with this and can take connection requests from clients then simply have the …

Member Avatar for L7Sqr
0
671
Member Avatar for hapag

One way that might be effective for you is to create a syntax tree based on the commands you support. For instance, the root of the tree is empty and the first level of the tree is all the verbs you support. The node below each supported verb could be …

Member Avatar for L7Sqr
0
311
Member Avatar for Lillylionhert

There are a few errors in your code. First, [icode]char delims[] = " ", "\n";[/icode] is invalid and your compiler should have told you so. You probably want something like [icode]char * delims = " \n";[/icode] Also, [icode]if (delims = " ")[/icode] is an assignment statement and in your code …

Member Avatar for Lillylionhert
0
5K
Member Avatar for devindamenuka

One critical error I see is that you are indexing your arrays starting at 1. In C++, arrays are indexed from 0 to n-1 where n is the number of elements in the array. This means that in some of your loops you are accessing one past the end of …

Member Avatar for cool_zephyr
0
402
Member Avatar for kkevinnnn

This sounds very much like an assignment you are to complete on your own. What have you investigated so far? What conclusions have you reached?

Member Avatar for mike_2000_17
-1
157
Member Avatar for Kanoisa

[QUOTE=Kanoisa;1729369]Can i use my ifstream file object with the cstyle fseek operation or do i need to figure out some kind of a workaround for that?[/QUOTE] [url=http://www.cplusplus.com/reference/iostream/istream/seekg/]seekg[/url]

Member Avatar for Kanoisa
0
1K
Member Avatar for Johnbonono

You may want to look into the [url=http://pm-utils.freedesktop.org/wiki/]pm-utils[/url] package. Have a look at [url=https://wiki.archlinux.org/index.php/Pm-utils#Creating_your_own_hooks]this[/url] for the behavior you are specifically after.

Member Avatar for L7Sqr
0
114
Member Avatar for ramanareddy438

To set an environment variable you usually export it in your shell configuration file. For instance, in [icode]bash[/icode] you would add an entry such as [icode]export CLASSPATH="/path/to/add:${CLASSPATH}"[/icode] to your [icode].bashrc[/icode]. Other shells may require a different syntax. It is hard to tell what problems you are having when you describe …

Member Avatar for ramanareddy438
0
242
Member Avatar for triumphost

If you want to support a small set of commands you can do so directly with a [icode]std::map< std::string, std::string >[/icode]. Simply read in tokens and map them to appropriate commands. If you want to support something more complex, as [b]ravenous[/b] suggests, you will have a bit more work to …

Member Avatar for triumphost
0
179
Member Avatar for joy39

MySQL provides [url=http://dev.mysql.com/doc/refman/5.0/en/c.html]some information[/url]

Member Avatar for L7Sqr
0
122
Member Avatar for asrockw7

In general, it is easier to run client/server test code in separate consoles. However, this requires a separate client and server. If you've combined them then you really have no choice but to force a particular order of operations and to 'take turns'

Member Avatar for nezachem
0
155
Member Avatar for lena1990

Data rate of the devices is fixed. Higher layer compression strategies do not change that value. Perhaps you are interested in the total goodput increase based on compression?

Member Avatar for L7Sqr
0
48
Member Avatar for s.w.a

Routers don't normally care. There are special cases such as throttling but these are not the general case with routers. Routers care about how to [i]route[/i] packets (frames, actually). The necessary information for that is determined on a frame-by-frame basis. A frame is received, the header is parsed, a source …

Member Avatar for L7Sqr
0
114
Member Avatar for s.w.a

HTTP is an application-layer protocol, TCP is a transport-layer protocol. You can not necessarily infer semantics of one from the other. To do what you are after you need to follow the HTTP [i]session[/i] and connect that with the TCP [i]streams[/i] related to it. There are tools that do this …

Member Avatar for L7Sqr
0
147
Member Avatar for MoreBloodWine

Perhaps try starting [icode]screen[/icode] in detached mode. Something like:[code]$ screen -d -m minecraft[/code]

Member Avatar for L7Sqr
0
85
Member Avatar for vignesh viki
Member Avatar for peter20

You could [url=http://en.wikipedia.org/wiki/Plagiarism_detection]search the web[/url]

Member Avatar for L7Sqr
0
303
Member Avatar for namratag
Re: map

[QUOTE=namratag;1694856]How to get value from key in map?[/QUOTE] A map can be indexed by the key to retrieve a value. So, given the key [icode]key[/icode] and the map [icode]table[/icode], you could get the value for key by way of [icode]table[key][/icode].

Member Avatar for L7Sqr
0
66
Member Avatar for lohath

The [icode]cin >> i1[/icode] is a [i]blocking[/i] call. That means it will wait forever for input to be available and you will not reach the sleep until the user enters something. You can wait for input to become available in linux by using [icode]select[/icode]. Example:[code]#include <stdio.h> #include <sys/select.h> int main …

Member Avatar for L7Sqr
0
130
Member Avatar for gman1991

Several observations about your code: [icode]string_dig1 = (char *)malloc(sizeof(char));[/icode] Allocates enough room for a single character - not an entire array of them. You need to allow for the largest input data you expect to get and take precautions against values greater than that. The fact that things have not …

Member Avatar for gman1991
0
238
Member Avatar for dancks

Either form should work correctly:[code]echo -e "$1\n$2\n" | cat >> $file # Or echo -e "$1\n$2\n" | cat - >> $file[/code]In the second form it is explicit that STDIN is the input file. Perhaps you should present a minimal working example of what fails so we can duplicate (including input/output …

Member Avatar for dancks
0
374
Member Avatar for BTW8892

Considering your original example line 27 is empty. Perhaps is would help us if you provided your updated source file.

Member Avatar for L7Sqr
0
86
Member Avatar for samerhaffar

You can place code to be executed in your lex source file and provide an implementation during compile time. A short example: [code]------ ex.l ------ %% a { foo (); } %% int main () { yylex (); return 0; } ------ ex.c ------ #include <stdio.h> void foo () { …

Member Avatar for L7Sqr
0
207
Member Avatar for vignesh viki

I've already [url=http://www.daniweb.com/software-development/shell-scripting/threads/400231]answered[/url] you.

Member Avatar for vignesh viki
0
63
Member Avatar for gourav1

What motivates you? Pick something that keeps you interested and find an unsolved problem in that space. That's about the extent of the equation.

Member Avatar for v3ga
0
90
Member Avatar for SakuraPink

Reading the contents into a variable is a simple task. Something like[code]VAR=`cat the.file`[/code]should do the trick for you. However, if you plan to access that data as an array of values (I'm assuming that this is your intent) then that will not work directly. To do that in Bash you …

Member Avatar for SakuraPink
0
240
Member Avatar for vignesh viki

I generally use the following syntax in Bash[code]if [[ "${STR3}" == "${STR1973}" ]]; then # This is match condition fi[/code] As an aside, it is generally more useful to you to experiment yourself with these types of trivial problems.

Member Avatar for L7Sqr
0
62
Member Avatar for D19ERY

[QUOTE=D19ERY;1714265]how would i incorporate the - a and - h features?[/QUOTE] See [url=http://www.mkssoftware.com/docs/man1/getopts.1.asp]getopts[/url]

Member Avatar for L7Sqr
0
252
Member Avatar for ricardo.crudo

[icode]sizeof[/icode] is a compile-time operation. The [icode]#if[/icode] is part of the translation phase (which happens before compilation). So you can not use the compiled results [i]before[/i] it is computed. You can either use a type that is designed for this already ([icode]uintptr_t[/icode]) or have your build system pass the value …

Member Avatar for ricardo.crudo
0
86
Member Avatar for vignesh viki

What have you tried so far? This is pretty straightforward and we will not do your homework for you. Topics to look into: [icode]${#}[/icode]: Number of command line arguments [icode]tr[/icode]: Translate between sets of characters [icode]ls[/icode]: Directory listing [icode]echo[/icode]: Printing to output device [icode]-d[/icode]: File test for directory You will …

Member Avatar for L7Sqr
0
250
Member Avatar for usustarr

Usually, you'd like to spawn the process in the background and [icode]wait[/icode] for it to complete. Unfortunately, there is no timeout parameter to the wait call. I can think of two immediate solutions. First, you can write a small C program that will execute the recovery script and timeout after …

Member Avatar for Fest3er
0
774
Member Avatar for schrei

[icode]pointer = sharedmem;[/icode] is pointer assignment. You will want to do a [icode]memcpy[/icode] to have that work the way you'd like.

Member Avatar for schrei
0
307
Member Avatar for arunsolo1984

What are your thoughts on the matter? We could certainly help correct any mistakes in your conclusions.

Member Avatar for L7Sqr
0
71
Member Avatar for bossman5000

Any chance you know [url=http://www.daniweb.com/software-development/shell-scripting/threads/389077]this person[/url]? My suggestion in that thread was that [icode]cut[/icode] and [icode]grep[/icode] are the wrong approach.

Member Avatar for tudloiako
0
432
Member Avatar for purpleturtle_97

The HTTP format is very well specified ([url=http://www.w3.org/Protocols/HTTP/1.0/spec.html]see here[/url]). You can simply pull apart the fields you need and ignore the ones you do not. That aside, I think that [b]wingless[/b] provides the best advice: use existing software.

Member Avatar for Adak
0
268
Member Avatar for jinna

You will likely want to break the problem down into two distinct parts: parsing input and managing the increment. If you parse the input properly then the increment should be trivial with the exception of propagation of the carry.

Member Avatar for Narue
0
2K
Member Avatar for monica23

Your probably mean to do something along the lines of [icode]if id > 1[/icode] instead of [icode]if id > '1'[/icode]. Notice the lack of single quotes in the first example.

Member Avatar for L7Sqr
0
116

The End.