825 Posted Topics
Re: The problem with redirecting to a file or using a subshell or similar technique is that the `yes` command is infinite. There is no terminating condition other than killing the process. There are ways to do this with *other* commands but something like `yes` is going to be problematic. Is … | |
Re: Instead of hooking keystrokes why not use the clipboard api to get notifications when the clipboard changes? ([clipboard](http://msdn.microsoft.com/en-us/library/windows/desktop/ms648709(v=vs.85).aspx)) | |
Re: From the selected answer in **Taywins** link: > I didn't notice the ampersand. You don't need it, inject will work with a symbol. But if you do write it, the symbol is converted to block, it can be useful with other methods | |
Re: A point of clarification. Every operation in Ruby returns some object. Usually, it is just the result of the last operation. Consider: irb(main):001:0> def foo &block irb(main):002:1> block.call irb(main):003:1> end => nil irb(main):004:0> foo { nil } => nil irb(main):005:0> foo { 42 } => 42 irb(main):006:0> foo { Hash.new(0) … | |
Re: You could start by issuing a directory listing of the files you'd like to copy `ssh user@server "ls -l"` Using that list you can evaluate how many files have been copied (by checking against your local listing) and only request the ones you do not have. N.B. This will not … | |
Re: `cout<<Entry[f];` That will only ever print the elements indicated by `f`. If `Entry.size()` is optimized away that will only ever be 3 (the original 3 items). You should be aware that you are modifying the size of teh vector while simultaneously using it's size as a stopping condition. This is … | |
Re: Try enclosing the entire `if` body in brackets. while(fgets(line, 200, file_in) != NULL){ if(line[0] == '>') { sscanf(line, "%s | %s | %s | %s | %s", part1, part2, part3, part4, part5); fprintf(file_out, "%s\n", part2); } } What you currently have functions, instead, like while(fgets(line, 200, file_in) != NULL){ if(line[0] … | |
Re: Try `GROUPS=$(($GROUPS + 1))` I'm not near a terminal so the syntax may be slightly different | |
Re: Presenting on the topic 'Linux' is as broad as presenting on the topic 'Color'. It is much easier to present on the color _blue_, or the color _red_, or a particular _shade_ of either of those. There are also composite colors, primary colors, secondary colors (both additive and subtractive), and … | |
Re: Can you give an example where ERB fails and you need something more flexible? | |
Re: If you want the linux version use a VM to run linux and install to that. There are also Windows versions available. My guess, however, is that you are going to be hard pressed to find a cluster of machines available for free to host your data processing; most services … | |
Re: The advantage of the second version (using `else if`) is that the condition is part of the *same construct*. That means if some condition within the `if/else if` tree equates to true then the processing of that tree stops and the code continues after the whole tree. In the case … | |
Re: First, you only allow for 3 names in you structure (`name[3][20]`) so copying 5 is going to do potentially bad things. `p->count++` increments the counter. There is no *if is does, if it doesn't* Also, I'm confused by your comments: > ... p->count will be 4. for this the loop … | |
Re: It may be that the quetions dealt with edge cases and they wanted to see if you'd catch them. It might also be the case that they had a candidate in mind and you were part of the process the company requires to allow a hire (must interview X candidates...). … | |
Re: I'd suggest you use a safer method to read input - `gets` is an unsafe operation. `fgets` can be used instead: char name[20] = {0}; fgets (name, 20, stdin); Also, `strcpy` expects the destination to be a pointer to a `char` array. You are providing a `char` (by indexing the … | |
Re: There is no reason why you cant have both streams open at the same time and continue to extract from both so long as there is data in each. For example (pseudocode): stream1 = open(1strow.txt); stream2 = open(2ndrow.txt); while (stream1.good and stream2.good) c1 = stream1.extract c2 = stream2.extract output c1 … | |
![]() | Re: `git` is the command name - it is what you are executing. If you want to have a program that does what `git` does then you create a script that will call `git`. If you want a script that does something entirely different you name it what you want and … |
Re: I cant say for sure without measuring but know that, in general, output streams are buffered. In particular, writing to disk is buffered by the OS. It is unlikely that you will notice a difference between writing a single line 1000 times or a 1000-line entry once. As far as … | |
![]() | Re: The signature of the function `pthread_create` expects to call is `void * function(void *)` and the fourth argument is a `void*` that is the argument passed to that function on thread creation. So, for example: void * printFunction(void * arg) { int * array = (int *)arg; // ... } … ![]() |
Re: It sounds to me like you may want to set up a bank of words/names that represent the set that are capable of mispellings. Once you have that, you might check each entry using [Levenshtein distance](http://en.wikipedia.org/wiki/Levenshtein_distance) to determine if a change is necessary. This is not straightforward. Consider the names … | |
Re: You can use a `char` in a switch. The reason that your first attempt failed is that a switch statement expects constant values in the case labels. So `('a' || 'A')` evaluates to true (most likely 1). Therefor you get a final expression that looks something like: switch (pick) { … | |
Re: You can do this fairly easily with AWK. Consider the following AWK script: { for (i = 1; i <= NF; i++) { printf("Parameter: %d: %s\n", i, $i) } } And run that like: `awk -f t.awk t.in` where teh above is in `t.awk` and your input is in `t.in` … | |
Re: That should probably be `-k 4` and not just `-4` in your example. | |
Re: `system` will not provide you with output. You need to using something like `popen` or the longhand version of that using `fork` and `exec`. These tools allow you to capture the output of a program that is run - you would use that output to construct a message to be … | |
Re: Hard to say if this falls within the > ... a variable or two as needed. requirement but you can construct a binary search tree which, by it's properties, is always sorted. Printing the sorted items requires only an inorder traversal of the tree. | |
Re: Usually, that department provides some sample topics for those who can not decide for themselves. Does your university not have this support? As far as course materials, this requires an actual course. If you have a course in mind, use a search engine to find the course website and request … | |
Re: What focus have you had over the past three years? You may want to design your thesis around something you have an existing body of work for; something that you are familiar with. Starting from scratch and expecting to be successful is not always the best approach. | |
Re: > use case for static data members If there is only ever a single `BankAccount` or the op wants a count across all accounts I would agree. However, if you did that with something like BankAccount mary; CheckingAccount jane; mary.Credit(100.00); mary.Debit(50.00); I think Jane would be surprised to hear about … | |
Re: > we have to use void main That doesn't make much sense. Why such a requirement? | |
Re: You dont need a server to connect computers; you need a way to forward/route packets. You can use a switch, router or basic computer to manage packets depending on what equipment you have a vailable. Once you have a way to route packets you need unique addresses for each of … | |
Re: You say obviously wrong. In what way? Does the book describe why this is considered bad (or undefined) behavior? | |
Re: You could use a `static` variable to manage the count for you. Fore example: class Account { static int next_account_number; int account_number; public: Account () : account_number(++next_account_number) {} int Number () const { return account_number; } }; int Account::next_account_number = 0; int main () { Account a, b, c, d; … | |
Re: Many of your questions can be answered, as **Ancient Dragon** suggests, by reading a book. Another appraoch that I find very useful (especially for C++ hidden behavior) is to write a small sample program to test things out. If you write a small class with a copy constructor, assignment operator, … | |
Re: You set `current=$x` and then look for `$current` to be something other than `$x`. What you probably want is to check `if [ $current -gt $max ]` and `if [ $current -lt $min ]`. Other than that your logic looks in order. | |
Re: There are tools that exist to do this already. Is there any reason to not use them? | |
![]() | Re: I'm not sure about claim to fame, but certainly what helped C++ gain momentum was the fact that a C programmer could pick it up fairly quickly and C programs were valid C++ programs. Templates are another huge gain. There are some other topics which you might look into: RAII, … |
Re: @Watael: It is not very useful to suggest reading the manual on a command you dont yet know. The point of the question was to determine `cp`; not to ask how to use it. Perhaps something along the lines of: "`cp` or `mv` will copy or move files, respectively. If … | |
Re: You say that you want all of [5] and the first half of [6] but your example does not show that. If you have `0101 1011` and `0111 1011` and you want the first with the 4 least significant bytes of the second you would get `0101 1011 1011`. Or, … | |
Re: You imply that you are attempting this with struct then go on to say that you must not use classes. You do realize that they are basically the same thing, right? | |
Re: These are both well studied and well documented. Have you looked at your course material or online at all? | |
Re: One would think that, with a degree in communications, you would avoid things such as 'pls' and 'cos'. As far as you concern: Did you know everything about communications before you started taking classes? Probably not, that is why you needed the classes. If you are interested in software engineering … | |
Re: There is a hidden benefit to education that is oftentimes overlooked (in my opinion). That is that you can interact with people who are already in the industry and get a leg up on your competition - even if it is for a little lower pay at first. Case in … | |
Re: **phorce** are you familiar with templates at all? They are a much nicer way to have the type-based behavior you are looking for. The question is independent of the singleton class (which could still be used). You could transition to something similar to // Two ways to create a Dog … | |
Re: You should have a look at [string.find](http://www.cplusplus.com/reference/string/string/find/). | |
Re: I would offer that you should contend the basis of the assignment. Anything that makes you use a construct that is to be used lightly (if at all) in a context it was not intended to support is flawed in my opinion. The `goto` can be used to implement control … | |
Re: Make is notorious for not working with spaces. The `client: ...` line should have - on the very next line - a command that starts with a single tab. If your editor expands tabs to spaces you will have problems. If you insert spaces you will have problems. | |
Re: It looks like CMake is [written in C++](http://cmake.org/gitweb?p=cmake.git;a=tree) | |
Re: Note that printing is often a slower process compared to in-memory computations. It is entirely possible that you have a race condition somewhere that is avoided simply by printing. Are you using threads? However, without any example of your code it is hard to make any sound judgement. So, as … | |
Re: My submission. A simple [calculator](http://www.daniweb.com/software-development/cpp/code/427500/calculator-using-shunting-yard-algorithm). Internally uses reverse polish notation format generated using shunting-yard algorithm. |
The End.