825 Posted Topics
Re: [code]$ export INDEXFILE=/path/to/index/file/index.html $ find . -type d -exec cp -i ${INDEXFILE} '{}' \;[/code] That copies [icode]${INDEXFILE}[/icode] interactively to every directory found below the execution point. N.B. Not tested. | |
Re: Have a look at the stream [icode]operator>>[/icode] [url=http://www.cplusplus.com/reference/iostream/istream/operator%3E%3E/]here[/url] and [icode]operator![/icode] [url=http://www.cplusplus.com/reference/iostream/ios/operatornot/]here[/url]. The extraction operator returns a reference to the stream, not a boolean value. You can check the stream state through its provided interface. | |
Re: That is a binary format. You will not be able to get original source code from that (other than ASM, of course). One tool you can use is [icode]readelf[/icode]. You can also use [icode]objdump[/icode] if you wish to get at the assembly of the program. | |
Re: That is just a macro that expands in your code snippet[code]class A { FRIEND_NEW protected: A(); };[/code] to [code]class A { template<class T> friend inline T* ::safe_new(const char*,int); protected: A(); };[/code] | |
Re: I'd suggest you read the contents into a [icode]std::string[/icode] and just use the [icode]substr[/icode] method to do the work for you. For example:[code]int main () { const std::string input = "GATCGAT"; std::size_t offset = 0, len = input.size (), window_step = 1; std::cout << "INPUT: " << input << std::endl; … | |
Re: In a makefile, the [icode]=[/icode] is destructive assignment. You may be looking for somethign more along the lines of: [code]OBJ = main.o ll.o[/code] or[code]OBJ = main.o OBJ += ll.o[/code] This is also apparent in the output of make where your compile line has only the [icode]ll.*[/icode] file names listed. | |
Re: You can use the c pre-processor to do this. The command [code]cpp -dM file.c[/code] will list out all macros define in [icode]file.c[/icode] (including built-in and included file macros). This will not expand these macros, look at the man pages for [icode]cpp[/icode] for details on how to do that. | |
Re: You are using the wrong data structure. You should use a vector, array, set or some other container than a string. With your example strings (which elements are characters) your union would be [icode]",12345"[/icode]. If you must use a string you are going to have to break it up into … | |
Re: [url=http://linux.die.net/man/2/exit]exit(2)[/url] and [url=http://linux.die.net/man/3/exit]exit(3)[/url] each have a good description. | |
Re: You want to check the stream - which is [icode]outData[/icode] in your case. That should look like:[code]if (outData.good ()) { // ... } outData.close ();[/code]The [icode]file[/icode] variable is not declared anywhere and that is what the coimpiler is complaining about. | |
Re: Have you tried playing around with the commands? [code]$ tr ':' ' ' < /etc/passwd | head -n 5 root x 0 0 root /root /bin/tcsh bin x 1 1 bin /bin /sbin/nologin daemon x 2 2 daemon /sbin /sbin/nologin adm x 3 4 adm /var/adm /sbin/nologin lp x 4 … | |
Re: How are you handling the input/output? Given that you can read from stdin and write to stdout why not just filter the input?[code] int main () { int c = 0; while (EOF != (c = fgetc (stdin))) { switch (c) { case '4': case '7': break; default: fputc (c, … | |
Re: If you can give a valid reason why we should earn your degree for you then perhaps you will get a valid answer. Until then, dont hold your breath. | |
Re: I'm not sure what either of "docs" or "environment is black" means specifically but you might try [url=http://clang.llvm.org/]clang[/url] which is a frontend for [url=http://llvm.org/]llvm[/url]. Very powerful toolset. Works on Windows and Linux. | |
Re: The idea of saving data to a file to later load into program-related data fields is known as [url=http://en.wikipedia.org/wiki/Marshalling_(computer_science)]marshalling[/url] | |
Re: Editors load file contents into memory. How that memory is stored is different for each editor but, for example purposes, you might consider it as a doubly linked list. The cursor is simply sitting at whatever node you are currently at in the list. Adding text on screen is equivalent … | |
Re: Just convert [code]struct Process { int id; Process *next; };[/code] to [code]struct Process { int id; state_t state; Process *next; };[/code]Where [icode]state_t[/icode] is defined as[code]enum state_t { READY, RUNNING , ... };[/code] Of course, you will need to fill that enumeration with as many states as you would like to … | |
Re: If the data you were looking for has been overwritten then you are pretty much out of luck unless you have forensics tools. If not, you may try to mount the drive on an external machine and iterate through the filesystem structure. If the file was just marked for deletion … | |
Re: Then you need to create a mapping from data type to size and store it in a file. Once you've done that just search that file for the data type you are interested in. Although, as [b]WaltP[/b] has already mentioned, the size of a type is available at compile time … | |
| |
Re: Here is a hint: it involves [icode]#include <cctype>[/icode] (or [icode]#include <locale>[/icode]) and [icode]std::isupper[/icode]. | |
Re: It might be better for you to sort each of [icode]file1[/icode] and [icode]file2[/icode] first. That way you can simply iterate through the file you want to filter removing any matches in the other file. Since the two will be sorted you can filter in a single pass instead of the … | |
Re: My guess is that you do not know what is stored in [icode]unsorted[/icode]. From the error message it looks like it is an array of arrays while you are expecting it to be a simple array of values. It is difficult to tell for sure without understanding the calling context. | |
Re: Iterate through the rows checking which columns are zeros. Build a new array of rows that are not all zeros while you are doing this. | |
Re: You are telling the write call (which is not looking for null terminated strings) to write up to 1024 bytes but only providing 11 bytes to be written. [icode]write[/icode] will happily try to continue to read from wherever [icode]"hello first"[/icode] is stored in memory for 1024 bytes. Since constant strings … | |
Re: That comment doesn't really make much sense. What do you mean by [i]data structure of a file[/i]? And how, exactly, is that in 'another file?' | |
Re: There are certain situations (usually concerning automation and repeatability) where you would like a machine to configure a particular way on boot. A common case is in a system like [url=http://www.emulab.net/]Emulab[/url] where there are potentially hundreds of machines that need to be configured and automated in a very particular way. … | |
Re: From the man pages: [code] EINVAL Invalid value for cmd or semid. Or: for a SEM_STAT operation, the index value specified in semid referred to an array slot that is currently unused. [/code] My guess is that [icode]l[/icode] - wherever it is defined - is not suited to be a … | |
Re: You could always just get the entire line and split it up by spaces:[code]line = gets return unless line line.chomp.split(/\s+/).each do |token| puts "Token: #{token}" end[/code]which will give you something like: [code]1 2 3 4 5 # this is the input Token: 1 Token: 2 Token: 3 Token: 4 Token: … | |
Re: You can use an environment variable:[code]$cat Makefile something: @echo ${MY_VAR} [/code] Then you can do something like:[code]$ MY_VAR="DATA" make DATA $[/code] | |
Re: Writing a linux driver is itself a non-trivial task. The topic is not meant for beginners so you will likely have trouble finding a basic tutorial. That being said, [url=http://tldp.org/LDP/lkmpg/2.6/html/]here[/url] is a step-by-step howto for creating a kernel module. | |
Re: It has to do with the way the call [icode]reverse(no--)[/icode] is being implemented. The post decrement operator allows for the variable to be used in it's context [i]before[/i] it is decremented. So, in your situation it is using the original value of [icode]no[/icode] for the recursive call and decrementing it … | |
Re: Bash has a really convenient way to get to that argument. You can use [icode]!$[/icode] which refers to the last argument in the preceding command. Consider:[code]$ pwd /home/me $ cp blah.txt /some/other/location $ cd !$ $ pwd /some/other/location[/code]And, since you probably only want to be there temporarily you can push … | |
Re: I'm not sure what you mean. If you are asking if the router is programmed using the Java programming language then the answer is likely no. Routers are designed to be as fast a possible at what they do. Generally speaking, Java doesn't provide the facilities to support things that … | |
Re: First, it is not usually a good idea to shadow loop counter variables like you have. A quick read over your code [i]looks[/i] like you never reset [icode]i[/icode] after the first loop. As far as your logic, add a few print statements and you will see what is happening immediately: … | |
Re: That statement doesnt make much sense. Do you want advice on how to program using [icode]awk[/icode] or would you like the source code to [i]build[/i] [icode]awk[/icode]? | |
Re: Perhaps this will help explain what the layout has to do with the output. If you compile the code to asm using [icode]gcc -S file.c[/icode] they you might see the following output:[code] .file "file.c" .section .rodata .LC0: .string "dcis" .LC1: .string "%s" .text[/code] Notice in the read-only section of the … | |
Re: Since you mention that you are already reading a book on the topic you must have some idea of the answers to these questions. However, to address some of the points: TCP is distinct from IP. I will describe TCP here as I believe that is what you mean, although … | |
Re: Another case of the failed expanded macro. If you expand that macro you will get the following: [code]int main() { int i, j = 10; int k = 15; for( i = 0; i < j > k ? j:k; i++ ) { printf( "\nhi" ); } return 0; }[/code] … | |
Re: The nice thing about TCP is that it manages so much for you under the hood. The problem with TCP is that it manages so much for you under the hood. There is the possibility, due to the send window, that you can have data sent by the client and … | |
Re: The [icode]#include[/icode] acts as a paste function for the file it targets. So when you say [icode]#include <ctime>[/icode], the file [icode]ctime[/icode] is located and it's contents are pasted directly in the place of the statement. What that [i]does[/i] is provide you with all of the declarations and code that is … | |
Re: You can use a case statement to get what you are after. For example: [code]#!/bin/bash LOG=/dev/null while read line; do case ${line} in 'AIR DR') LOG='air_dr.out' ;; 'AIR UR') LOG='air_ur.out' ;; 'WATER DR') LOG='water_dr.out' ;; 'WATER UR') LOG='water_ur.out' ;; *) echo ${line} >> ${LOG} ;; esac done < results.txt[/code] | |
Re: Why [icode]awk[/icode]? Ruby (or similar scripting language) would make this trivial as there would be no need to modify the input line. For instance: [code=ruby]#!/usr/bin/env ruby require 'time' two_hours = 60 * 60 * 2 while line = gets ts = Time.parse(line.chomp) now = Time.now if now - ts < … | |
Re: If there is no need to store the data for later use in the file you might do better to use a socket or named pipe. Your application can write to the one end of the pipe and the php script can read from the other end when data is … | |
Re: And I need to know the next guy we hire has not farmed out his homework/tests to the internet. Thanks! | |
Re: How about [URL="http://ndk-xx.sourceforge.net/"]http://ndk-xx.sourceforge.net/[/URL]? | |
Re: It's unlikely that what you describe is happening. Consider[code]#include <cstring> #include <cstdio> const char url[] = "www.google.com/"; int main () { char * pos = strrchr (url, '/'); if (pos) { printf ("Found / in %s\n", url); } return 0; }[/code] I've run that 100 times each time the '/' … | |
Re: How about [url=http://www.cplusplus.com/reference/string/string/find_first_not_of/]find_first_not_of[/url]? | |
Re: I'm not sure what you mean by [i]readable[/i] values. Certainly hex is readable. I suppose you would like the number in a different [i]base[/i] than 16. If you are outputting to the screen then you can just format the output however you like since values are stored internally not related … | |
Re: [icode]popen[/icode] creates another process and manages the pipe setup for you. It calls [icode]fork[/icode] (in linux) and I'm not sure how the child process is executed in Windows. This is different than using something such as [icode]pthreads[/icode] to run multiple threads in the same process space. |
The End.