825 Posted Topics
Re: Couple of things: [icode]puts "sum"[/icode] just outputs the string [icode]sum[/icode] not the value of the variable. If you'd like that you need to do something like [icode]puts "#{sum}"[/icode] or, simply [icode]puts sum[/icode]. As for the addition, I'm not sure if you are looking to do string concatenation or a value … | |
Re: You can use [icode]printf[/icode] in C++. Just [icode]#include <cstdio>[/icode]. You will want to declare [icode]main[/icode] as being of type [icode]int[/icode] and will likely want to provide a return value. | |
Re: Struct (or arrays of structs) can only be populated in the form you show at declaration. So to do what you want you need to do one of the following: [code]strncpy (stock[0].title, "example title1", 40); strncpy (stock[0].author, "example author1", 40); stock[0].edition = 1; stock[0].retail_price 5.80;[/code] or [code] book stock[10] = … | |
Re: Find a problem; solve it with shell scripts. You are starting at the wrong location. A language by itself is meaningless. If you want to learn how to solve problems [i]using[/i] a language then you first need to define a problem and then proceed. Your request is very much like … | |
Re: If you are going to use a file-based approach why not use something that is somewhat more robust? [url=http://linux.die.net/man/1/lockfile]lockfile[/url] already accomplishes what [b]Gromit[/b] suggests but provide a more standard means to achieve it. | |
Re: [code]VALUE=100 VALUE=$((VALUE + 20))[/code] That should answer both of your open questions. | |
Re: If you are on a Windows box then UNIX time is pretty useless, yes? Maybe you want something like 'seconds since the epoch' or similar to that? | |
Re: There are several online networking tutorials online (Beej is a good google term) - I'll assume that you have read these and will ask direct questions on points you do not understand. The answer to your question, then, is that you[LIST] [*]open socket, listen and accept the client connection [*]read … | |
Re: As I understand what I've [just] read about Manhattan distance it is a comparison between two points. That requires at least 2 x-values and 2 y-values. How do you expect to sort based on that requirement with just a list of [icode]int[/icode] values? Or have I missed something entirely? | |
Re: You are not going to get [icode]Mbps[/icode] speedup by changing from C# to C++. How many times did you run this test? What was the state of your network when you ran these tests? Getting double the [i]transfer[/i] rate is indicative of a network problem, not a code problem. [NOTE]: … | |
Re: My first question is whether or not you [i][u]must[/i][/u] do this as a shell script of if you can use something more suited to the task - such as perl, ruby, or python? | |
Re: Why not filter on the values you [i]do[/i] wat to allow? Something like:[code]temp.gsub(/./) { |c| if (65..90).include? c.ord or (97..122).include? c.ord c else "" end }[/code] | |
Re: [url=http://www.daniweb.com/software-development/shell-scripting/threads/389077]This[/url] is a good thread to get you started. | |
Re: A memory location has an address. Depending on your system the size of that address will vary. If you need to address 64 bits you will need more digits than addressing 32 bits. You may have been seen a hypothetical scenario where the numbers were used to in crease clarity … | |
Re: Here are a couple of hints to get you going: [list] [*] [icode]${#}[/icode] reports the number of arguments currently available [*] [icode]shift[/icode] decrements the number of available arguments[/list] Combining those two should give you ample ammunition for a while loop. The construct, by the way, is[code]while [[ ${CONDITION} ]]; do … | |
Re: Your problem may be that the [icode]excludeDir[/icode] is running in a subshell and not giving you the effect you want. Perhaps something like the following would work?[code]for i in /Users/*; do if [[ -d ${i} ]]; then excludeDir ${i} if [[ $? -eq 0 ]]; then echo ${i} fi fi … | |
Re: In stead of storing the entire trace and checking against that why not store some representation of that? For instance, a [icode]md5sum[/icode] takes negligible time on my system for a 13K file. You could store the MD5 of the unique traces you find and for each new one only do … | |
Re: Without context, that makes no sense to me. It could be a user-defined function in a program. It could be a little know API method for some package you have installed. It could be a compilation error. Where did you find/see this code? What is the surrounding context? | |
Re: Any reason you couldnt use [icode]system[/icode] to do this? It is a blocking call so you'd have to wait until the other process returned or you could look into something like [url=http://msdn.microsoft.com/en-gb/library/t7y6z6fd(VS.80).aspx]_spawnlp[/url] with [icode]_P_NOWAIT[/icode]. | |
Re: First, you need a way to determine the last 100 lines. getline with a fixed-size buffer sounds like a start there. Then you iterate over only the lines left in the buffer. | |
Re: In general, hijacking a 3-year-old thread is not a good start. As for your question, you decrease the width by putting less things in the cell. If, on the other hand, you are reading a CSV file and the contents are being imported in another format you need to configure … | |
Re: This answer will be very similar to the directions [url=http://www.daniweb.com/software-development/c/threads/392126]here[/url] with the exception that instead of handling the file contents you will want to use the OS API for listing files within a program and write [i]that[/i] to the client instead of the file contents. | |
Re: THe following line [code]if(favorite == info[n].weapon)[/code]Should probably be[code]if(favorite == fencers[n].weapon)[/code] Similar to the way you handle things in [icode]getTeam[/icode] | |
Re: Redirection works on each output stream from the program. So, for instance, if your called program writes to stdout and stderr then you need to capture and redirect both. Example:[code] # Redirect only stdout some/bin/program >/dev/null # Redirect only stderr some/bin/program 2>/dev/null # Redirect both stdout and stderr (to individual … | |
Re: In general, [icode]tcpdump[/icode] or [icode]wireshark[/icode] are useful tools in this respect. | |
Re: Well, the error you are seeing is due to the fact that you haven't linked against the cirl library for your system (on linux-like systems this would look something like [icode]-lcurl[/icode] as a parameter to the compiler). Also, [icode]popen[/icode] takes a program name to execute as if you were going … | |
Re: How about something along the lines of[code]sed -e 's/'3428$i'/'$((3428$i + 10*$j))'/g'[/code] | |
Re: If the format of one array determines the output of the other it might just be better to have a 'mapping' from one to the other. For instance, to map ints to strings you might do[code]std::map< int, std::string > months; months[1] = "January"; months[2] = "February"; // ... and so … | |
Re: This is a non-trivial task. There are many questions that you've left unanswered to help us help you. As an assignment, is this part of some larger context system you must fit into? For instance, is there an API for communicating with your upper and lower layers? Are you using … | |
Re: If you are using [icode]bash[/icode] just execute the file with the [icode]-x[/icode] flag. Consider the following:[code] $ cat t.sh #!/bin/bash echo "Foo" >&2 echo "Bar" >&1 $ bash t.sh Foo Bar $ bash -x t.sh + echo Foo Foo + echo Bar Bar $ [/code] You can see that not … | |
Re: [QUOTE=Clinton Portis;1672550]Here is a general progression for using large numbers: 1. use a standard variable [/QUOTE] What is a [i]standard[/i] variable? I assume that you mean something smaller than a [icode]long[/icode], but there are several, so you should specify. [QUOTE=Clinton Portis;1672550] 5. use a c-string buffer[/QUOTE] I'd seriously caution against … | |
Re: If the original drive was bad, what makes you think that the numbers it's reporting are valid? If you find that the numbers [i]are[/i] good then I would suggest you start with the list of files that had problems and you had to replace with backups. Do a [icode]diff[/icode] on … | |
Re: I'm not familiar with SugarCRM, but [icode]cron[/icode] has online [url=http://unixgeeks.org/security/newbie/unix/cron-1.html]resources[/url] readily available. | |
Re: [icode]*x[/icode] is a way to access the first element of the character array [icode]x[/icode]. To do what you want properly, you need to iterate over all elements of the string and convert each in turn while properly maintaining the resulting value. As a hint, you may think of the following:[code] … | |
Re: Ruby is a scripting language. It requires an interpreter - either command-line or embedded. It has a syntax that you must abide - though it is looser than many other languages. It is not all that different from PHP except that Ruby doesn't focus [almost] exclusively on the web as … | |
Re: By EXE (and C#) I assume that this was compiled on a Windows-based machine? If so, no. You can not run an executable compiled for one platform on another. | |
Re: One way to count lines in a file is to count what you consider to be line delimiters. For instance, if your lines are terminated with [icode]\n[/icode] then you can iterate through the file character-by-character and count the number of times you see that character. That (plus one) will be … | |
Re: You can either not put [icode]wget[/icode] in the background (drop the [icode]-b[/icode] flag) or you can issue a [icode]wait[/icode] (without arguments) directly after your loop. | |
Re: Most switches have some level of native throttling at fixed speeds (they usually cant do too many). If those levels are not enough you might think of using [url=http://info.iet.unipi.it/~luigi/dummynet/]Dummynet[/url] between the gateway device and the clients (or just after the gateway device depending on your setup). Dummynet allows you to … | |
Re: The following works for me:[code]#include <iostream> #include <vector> class Outer { struct Inner { int i_; Inner(int i) : i_(i) {} }; std::vector< Inner > vinner; public: int construct (int i) { vinner.push_back (Inner(i)); return vinner.size() - 1; } int get (int i) { return vinner[i].i_; } }; int main … | |
Re: [icode]sftp[/icode] can pass flags directly to [icode]ssh[/icode] so you may want to investigate that. Also there is a [icode]-v[/icode] flag you can use which increasing logging (also passed directly to [icode]ssh[/icode]). | |
Re: Depends on the network and hardware. Your question is similar to asking which is faster: wind or rain? | |
Re: Every single category you provide is so vast that you would have a hard time scratching the surface (of just one) for a final year project. In your second post, you are closer to what a [i][b]feasible[/b][/i] final year project might consist of. Certainly, protocol enhancement and design are manageable … | |
Re: Names and movies are not integers. Perhaps you should consider another data structure. Maybe an array of something like:[code]struct { char * name; char * movie; int rating; }[/code] | |
Re: There is a huge amount of context missing here. For instance, are the lists always arranged such that the subset list (LIST A) is the first N items to appear in the full list (LIST B)? Without any insight I'd suggest that the only thing you can base the difference … | |
![]() | Re: I think your shared use of the pipe in each child is causing you trouble. Also, the fork logic there is a little convoluted and harder to follow. Here is something that allows two children to spawn, write to their own pipes, and have the parent receive the messages. It … ![]() |
Re: [icode]0x80487d2 != "80487d2"[/icode] | |
Re: [QUOTE=rubberman;1646650] 5) You need to look at the MAC addresses associated with each connection [/QUOTE] Side note: You can not get this information unless your custom protocol provides it. They way layer 2 works is that you will only see the MAC address of the previous hop which is generally … | |
Re: There is nothing preventing you from opening a socket on your windows machine and connecting to a linux machine on the other end. If you want a good introduction to the topic (for both windows and linux) you can search for Beej's guide to networking. There are also third-party libraries … |
The End.