825 Posted Topics
Re: What is the error you get? | |
Re: @Gonbe - Do you think it would be better for someone trying to learn to get an informed nudge or suggestion rather than a working solution? Often times a full solution only serves to further bury a person struggling with the basics. | |
Re: Use cron to manage to recurring task. Check the file for conditions (there is not enough information in your post to determine the best way to do that). If conditions warrant an alert use a mail client (`mutt` is a good choice) to send yourself an email. | |
Re: What is your description of a token? That would be a logical place to start. | |
Re: @rubberman: I think the comment was to mean that he had been working on it already for two days without luck. The link is to an online progreamming competition so I doubt this is an assignment, per se. | |
Re: That's not even valid C code. Unless you specify what `scanf(*)` does and what `eof` is there is no way to answer this quetion. | |
Re: Talk to an office worker or school administrator. Ask them what would be useful in the day-to-day operations that they do not already have. I'm sure you will get relevant information from that. | |
Re: Since you are using (presumably well-formed) XML, why not just use a scripting language with XML libraries (Ruby, Python, Perl, etc) to do this? | |
Re: I believe you are over-thinking this. Try to abstract the problem into something you already understand. Here is a hint: ones, tens, hundreds, thousands, ... | |
Re: Firstly, source code does not run; it is compiled. It is possible to compile the same source code on multiple platforms but only if you write portable code. Using system-specific utilities will tie to you a particular platform and porting will be next to impossible. It's aslo unclear whether `console.write` … | |
Re: If you do not understand the concept of loops then no tutorial on drawing borders is going to help. Perhaps you should start by trying to use a loop to draw a straight line of a given size. From there, you can begin to extend your approach to multiple nested … | |
Re: `x+y` evaluates to a single integral value. You probably intended to write that as: `z = addem(x, y);` | |
Re: Your compiler should choke on that input. The diagnostics may or may not be useful, you have not indicated. A proper `if` construct looks something like: if (condition) { // code for this condition } else if (some_other_condition) { // code here } else { // catch-all case in the … | |
Re: You could also use [memcmp](http://www.cplusplus.com/reference/clibrary/cstring/memcmp/) | |
Re: No. Redirection, piping and general screen printing are facilities of the OS, not your program. Additionally, there are other tools, such as `tee` which would complicate the matter if you could. Suppose you had `./a.out | tee a.txt` would you want that `tee` was receiving your output or that it … | |
Re: Well, you can't expect `"ff" != ...` to do what you want. Checking for ethernet broadcast means looking for all `0xff`. Something like unsigned char bcast_addr[6] = {0xff}; if (memcmp (bcast_addr, ether->dst_addr) == 0) { // This is a broadcast packet } This would explain why you are not capturing … | |
![]() | Re: Dynamic programming most times revolves around caching or memoization generally coupled with some sort of recursion. The idea in this case would look something like: for each Node1 in Graph: set Node1 as Root. for each Node2 in (Graph - Node1): calculate ShortestPath(Root, Node2) print ShortestPath(NodeA, NodeB) The `ShortestPath` would … |
Re: Welcome to multi-platform. Things that are not specified by the standard (such as directory traversal) are left to system implementors. You may get some support from standards like POSIX but even then, you are back to requiring POSIX. | |
Re: You may also want to have a look at [AutoIt](http://www.autoitscript.com/site/autoit/) It might save you the trouble of re-inventing the wheel if you dont need the gritty details. | |
Re: Try experimenting with the following to better understand the relationship between `%` and `/`: #include <stdio.h> int main () { int x = 10, i = 0; for (; i < 30; ++i) { printf ("%02d %% %d = %d\n", i, x, i % x); printf ("%02d / %d = … | |
Re: In your inner loop you are incrementing `i` instead of `j`. I cant tell if this is a copy-paste error or not but it would lead to a result other than what you want and what you are getting. Please paste the *actual* code you are using so that we … | |
Re: You can copy to a vector in a number of ways. Use an iterator std::vector<unsigned char> out; unsigned char buff[1204] = {0}; // ... std::copy (buff, buff + 1024, std::back_inserter(out)); Or, since vector elements are guaranteed to be stored contiguously in memory, you can asign directly to reserved memory std::vector<unsigned … | |
Re: If each of the calls depends on the previous one rturning a `true` value then you can use the `&&` operator to chain them. Something like: if ( func1() && func2() && func3() && func4() ) { std::cout << "Success!" << std::endl; } else { std::cout << "Error at some … | |
Re: That looks like perl. `tr` translates the first set of characters (empty in your case) to the second set of characters and returns the count. With an empty set that is basically a no-op. Perhaps there was a copy-paste error from where you pulled this script? | |
Re: > i am using snprintf and also strtoul Where? `strtol` will allow you to grab numeric values while stepping through a string (although if you include hex the soultion becomes ambiguous). | |
Re: While `Wireshark` is a great tool I, think it is a little hard to digest for something as simple as grabbing packets. It is probably easier to concentrate on the underlying [libpcap](http://www.tcpdump.org/) to get started and move up from there. | |
Re: That is the exact job of `uniq`. Why would you want to exclude that from your solution set? ![]() | |
Re: Many times, when developers release code for the masses it is done as a library. This makes the integration easier for the end developer. What exactly is it you are looking for? | |
Re: [time](http://linux.die.net/man/2/time) gives the time in seconds. Feeding that to [srandom](http://linux.die.net/man/3/srandom) seeds the pseudo random number generator based on the time of day. | |
Re: You have a couple of options. * Since this is 'just for you' then just run the entire program as root * Run the program as root, but [drop priveleges](http://linux.die.net/man/2/setuid) once you open the file * Use a combination of the two above and run as root, fork a child … | |
Re: I'd break this up into manageable pieces: * Define a function that will calculate (and return) an area given a width and height * Layout the main function to have the original width and height variables * call the area function with the original values * output the result * … | |
![]() | Re: Instead of trying to get back to the middle of a function why dont you just break it up into multiple functions to begin with? Something like: int main () { /* do all output thing here as you already have */ cout << "This is enigma machine:" << endl; … |
Re: It is an active field as the kernel is constantly in motion. Your best bet would be to download the latest kernel source code and look at how current drivers are implemented. Once you have that build questions around items you can not understand - it will increase the likelihood … | |
Re: In general, a lexer expects input. If you do not specifically write a prompt to display it will just quietly wait for input. | |
| |
Re: Instead of just outputting the values save them to a container. Then each new value you select from the original list can be checked against your new list for uniqueness. Something like: std::set< int > unique; while (unique.size () < 4) { f[i] = rand() % 7; s[i] = rand() … | |
Re: `pwd` will print the working directory. Or, `${PWD}` | |
![]() | Re: I have found that bit fields can be useful when you want to provide a set of non-overlapping options. For example, suppose you provide a filter for the categories of things you want to output in a logging function you may set up the following: #define LOG_DEBUG (1<<0) #define LOG_ERROR … |
Re: You mention an exact requirement, then relax that to allow for a variable amount of delay. How critical is this timer? Are you sure you aren't just interested in having a query execute every second or so? If so the timer you set up will allow for that. However, how … | |
Re: Instead of copying the file all around you can just extract it to your chosen location directly. Consider: $ pwd /home/you/ $ tar xjvf /mnt/lfs/sources/binutils-2.22.tar.bz2 Also, you might try to run `file` on the file to make sure it is not named incorrectly. | |
Re: The minimum speed is 0. The maximum is determined by the [Bandwidth-Delay Product](http://en.wikipedia.org/wiki/Bandwidth-delay_product). There are many factors such as contention, medium, distance, and loss that factor into the equation so it is not an easy answer to provide in general. | |
Re: You are only fooling others (and yourself) if you think that being handed a clever trick constitutes you 'knowing how to hack.' If you want to impress someone or show your prowess *do the work*. Investigate a particular feature or piece software and learn how to touch it's edge cases. … | |
![]() | Re: Why people like a particular OS is purely a personal matter - all replies you get will be subjective. That being said, here is my $0.02. I use both to some extent - which one depends entirely on the task at hand. For instance, I take classes remotely and the … ![]() |
Re: The simple solution is a recursive one. In pseducode that would look like: int quad_max(root) { if (root.is_a_leaf) { return root.value } else { return max( quad_max(root.east), quad_max(root.south), quad_max(root.west), quad_max(root.north)) } } Although, to be efficient you would probably want to implement a caching scheme to that search to prevent … | |
Re: What numeric system do you know where `1 + 3 = 5`? | |
![]() | Re: This is a subjective question; you will likely only get opinions as answers. My opinion is that Ruby is very nicely geared to this type of work. Perl is probably the most popular but I find the syntax prohibitive and Ruby grabs many of the most useful features from Perl … |
Re: You may also want to look into [pthread_join](http://pubs.opengroup.org/onlinepubs/7908799/xsh/pthread_join.html) | |
Re: Here is a simple ruby script that will (from the directory you call it in) give you all files (recursively) with full path names changing `/` to `_`. require 'pathname' Dir['**/*'].each { |f| puts Pathname(f).to_s.gsub('/', '_') } So the output is something like: ... new_gcc_gcc-4.7.1_libgo_go_image_png_testdata_pngsuite_basn0g01-30.sng new_gcc_gcc-4.7.1_libgo_go_image_png_testdata_pngsuite_basn2c16.sng new_gcc_gcc-4.7.1_libgo_go_image_png_testdata_pngsuite_basn3p01.sng new_gcc_gcc-4.7.1_libgo_go_image_png_testdata_pngsuite_basn0g02.png new_gcc_gcc-4.7.1_libgo_go_image_png_testdata_pngsuite_basn0g04-31.sng new_gcc_gcc-4.7.1_libgo_go_image_png_testdata_pngsuite_basn3p08.png … | |
Re: To do this just keep track of the length of the longest name and use that. For example: int main () { std::vector< std::string > names; std::string name; size_t long_name = 0; while (std::cin >> name) { long_name = std::max (long_name, name.size()); names.push_back (name); } for (std::vector< std::string >::iterator it … |
The End.