506 Posted Topics
Re: Given you're using std::string you have many easy alternatives: 1. Use basic_string substr(size_type pos = 0, size_type n = npos) const; Returns a string composed of copies of the lesser of [U]n[/U] and [U]size[/U]() characters in this string starting at index [U]pos[/U]. Throws an [U]out[/U]_[U]of[/U]_[U]range[/U] exception if [U]pos[/U] > [U]size[/U](). … | |
Re: What is done in this part of the code is correct: [code=c]if ((pid = fork()) == 0) // this is the child { n_child+=1; /*incremento contatore figli*/ Close (listenfd); /* avvia add server*/ add_server (connfd); calcola (connfd); /* chiude la connessione*/ Close (connfd); n_child-=1; /*decremento contatore dei figli*/ } else … | |
Re: 1. I didn't know that binary searches work on un-sorted list. 2. For the last if thing not working I think it's a flushing problem try this: [code=c++] if (arra[mid]!=num) //NOTE THE EXTRA flush AT END. //FYI endl = flush + "\n" (so that can also be used) cout<<"\nnot found" … | |
Re: - The code doesn't compile. - Who calls whom is not clear. - mp_entries is never called. - You open c:\p\temp for reading and writing it's only written to. Is this okay? Finally I personally have always felt it's much much much easier to use fprintf() for formatted printing rather … ![]() | |
Re: Following is not clear: 1. Why is there a 2D array for hours? What does it indicate/store? 2. Why do "[B]empl_name_ptr[0] + 1[/B]" in the code? What's the aim? 3. If you are expected to use C++, why not use STL containers? vector/map etc. Would be much easier. Here are … | |
Re: As you've given too much of information I have no clue where and what to look for, but I think this must be the problem: #define strdup my_strdup Somewhere in [B][COLOR=Red][COLOR=Blue]mygetopt.c[/COLOR][/COLOR][/B]. you must be #including string.h AFTER this #define. So the strdup [B]inside string.h[/B] is getting converted (by preprocessor) to … | |
Re: Something more than "This code wont run at all right now" would be helpful. :) I don't see why you would want to keep resizeing your vector. It's simply not needed to start with. I would suggest just comment out that code, let vector resize by itself, later when things … | |
Re: STFW Here is what I found for you: [code=C++] while (fscanf(in_fd, "%s", username) != EOF) { fprintf(out_fd, "%s\n", username); } [/code] PS: Remember fscanf returns EOF in case of errors or if it reaches eof. So you can check return value of fscanf instead of feof(). | |
Re: It's a concept in most OO languages. You'll need some of it, before you start posting in this forum. So don't mind but you need to do some homework. Search teh web I'm sure you'll find plenty. | |
Re: Does cygwin have any kinda support for signal handling? If yes d'u know which is the file that defines teh signals... ? | |
Re: Line 27 and 28: [code=C++]x = growthRate( birthRate , deathRate ) ; population = estimatedPopulation ( growthRate , cPopulation, n ) ;[/code] SHould either be: [code=C++]x = growthRate( birthRate , deathRate ) ; population = estimatedPopulation ( x, cPopulation, n ) ;[/code] OR [code=C++]//x = growthRate( birthRate , deathRate ) … | |
Re: Well you've gotta have some common place to store the values of these buttons.. So may be have a class (say my_container) to contain these values. Catch is both the button's handler classes must have access to same object of this my_container class. You can do this is with [URL="http://en.wikipedia.org/wiki/Singleton_pattern"]Singleton … | |
Re: Post your code.. Don't forget teh code tags. Attach if it's big. | |
Re: There is always a way.. :) 1. See "man -s 4 proc" 2. See "man -s 1 proc" If you donno much abt this kinda programming, it might be easier if you run system("ps -eaf | awk ... > tmp.file") from C++ and then just parse this file. "..." is … | |
Re: [code=c++]while ( !airportsMaster.eof()) { airportsMaster.getline(icaoChr, 5,','); for ( int i=0; i<(numAirports); i++ ) { if (icaoChr == icaoStr[i]) { airportsList << icaoStr[i] << ","; airportsMaster.getline(tempChr, 35,'\n'); airportsList << tempChr << "\n"; } } airportsMaster.ignore(35, '\n'); }[/code] You have already extracted teh '\n' on line 10. It really isn't THAT obvious … | |
Re: A little more info would help, like what are you trying to do?? What is teh command you use to run and EXACT msg in the msg box... | |
Re: So what's teh question and where is teh "class Scanner " ? | |
![]() | Re: 1. Give complete information. E.g. error msg (as printed on your console) so we know which line are we talking abt... ?? 2. Is the error runtime or compile time?? 3. Without that info all I can say/guess is there might be some unsatisfied linking kinda error. Assuming it's a … ![]() |
Re: [quote=masijade;330148]df[/quote] Means look up "man df" | |
Re: I didn't really get what you wanna do, stupid it may sound but if what you want all 250 .temp_as_$fname/IDX_Issue.txt and .temp_as_$fname/TXT_Issue.txt files concatenated into one single file (or 2 files) you can do this: [code=sh]for f in .temp_as_*/TXT_Issue.txt do echo '-----------------------------------' >> ./consolidated_TXT_file.txt cat $f >> ./consolidated_TXT_file.txt done #do … | |
Re: Use awk (hint: Use getline()). Post your code and I'll correct it. | |
Re: Seems like you're writing C code in some C++ IDE. (variables declared after function calls). If this is for some small part of with some project of yours easiest would be to [URL="http://www.fredosaurus.com/notes-cpp/algorithms/sorting/stl-sort-arrays.html"]#include <algorithm> and use std::sort()[/URL]. If this is some assignment you can either use what Luckychap posted (Bubble … | |
Re: To detect the order you need some help from teh algorithm, no outside code can independencly establish that. The order of the algorithm means how many operations would the algo perform to sort a list of 'n' elements. Bubble sort is of order n*n (i.e. n-square). Anyway, just increment a … | |
Re: [code=C++]#include<iostream.h> #include<conio.h> void main() { int x, y, c = 0; clrscr(); cout<<"\nPrime Numbers upto 100 :\n "; for( x = 2; x < 100; x++ ) { //check only odd numbers, even are never prime. if( x % 2 != 0 || x == 2 ) { //if an … | |
Re: It's a bit strang, but you never know the compilers... Try: rectangle theRect2; Instead of: rectangle theRect2[B]()[/B]; | |
Re: Sure. [URL="http://www.daniweb.com/techtalkforums/announcement8-2.html"]Here it is[/URL]. | |
Re: What Narue means is [URL="http://www.daniweb.com/techtalkforums/announcement8-2.html"]We only give homework help to those who show effort..[/URL] Post the code you've done and ppl will tell what's wrong.. | |
Re: Post the declarations of m_task_t and m_host_t and this time [URL="http://www.daniweb.com/techtalkforums/announcement8-3.html"]use BB code tags[/URL]. Is m_task_t some kinda pointer? Or the following code is wrong.. m_task_t *todo = NULL; m_task_t task = NULL; Don't write normal code within asserts ([URL="http://www.codeproject.com/debug/releasemode.asp"]usually they are removed by pre-processor in release mode[/URL]). Finally a … | |
Re: What are you trying to do? web-page, data crunching, simple test programs.. ?? Anyway all I remember is that from C++ you just gotta print the chars as they are, depending on where they are being printed (on console/web-page...) it'll appear appropriately ! I.e. if the fonts are appropriately installed … | |
Re: Hope this is not what you posted it for: test.cpp(43) : warning C4700: local variable 'linePtr' used without having been initialized Line 43 in my test.cpp is "*linePtr = line[k];" | |
Re: Code is okay.. May be the pre-processor is screwing up somewehre. Do only preprocessing and check the output. Also hope that you've posted complete code. Is the error in .cpp or .h? What compiler are you using? Don't do "using namespace std;" in header file. You'll run into trouble when … | |
Re: If you're using command line for compilation add [B]-I<include-path>[/B] option where include-path is the path that has your header file. Another option (quick-fix) is to give full path e.g. #include "/home/nayrb/include/my_header.h" Don't make this a practice. Finally if you're using some IDE, answer SOS's question. :) | |
Re: >> Alt = time * velocity It should be: Alt_after_time_t = orig_alt - ( t * velocity ) May be if you clarify what are you trying to achieve, that'll help. If you have some problem statement post that... Also the code is not compile clean. Update so others don't … | |
Re: Could also use the buttons at right top (of the Quick Reply box) to increase the size of box, at least vertically, if your "quick reply" is growing beyond a few pages.. :) | |
Re: Not clear why would you want to compare 2 vectors (it's a sequential container) but... First compare the sizes of them if that matches Write a for loop and compare element by element.. ! | |
Re: Post the code you've already written and we'll tell you what's wrong with it. | |
Re: You really gotta learn and use "functions".. For the problem at hand try [URL="http://astyle.sourceforge.net"]AStyle[/URL] if it helps.. | |
Re: I suppose you donno how to use scanf(). As you said you know java let me just say: System.out.ptintln() = printf() System.in.read() = scanf() Here is a sample: [code=c++]//Just gave a name to your struct.. struct TeamInfo { char team[20]; int played; int points; int goalsf; int goalsa; int goalsd; … | |
Hello Everyone, Does anyone know any design patterns for modules meant for encoding/decoding of protocol messages. E.g. BSSMAP/LAP... We need to write encoders and decoders for BSSMAP and BSSLAP messages for our product. All the IE (information elements) are defined by standards, so we know everything abt every field in … | |
Re: [code=c]char* bname[] = { "Unix Environment", "Programming in Perl", "Comp. Architechture", "Operating System", "Java Programming", "DIstributed OS", "Database Management", "J2ME","Operating Systems", "Algorithms in C++"} ; [/code] | |
Re: >> So shaving nanoseconds is important to a degree. Are virtuals really that bad? Virtual functions [B]will[/B] make a difference at nanosec level. But they improve maintainability many a times over. >> UNTIL they hit certain objects.......type of object You talked abt [I]base class[/I], and [I]type of objects[/I] and [I]certain … | |
Re: Both answers above are correct. I tested the code in my Unix machine and surprisingly it worked fine. :). Here I just found some code in my project where we use trapazoidal integration for Positioning Algorithm. Please don't ask me any questions regarding the maths that goes behind this I … | |
Re: Looking at the declaration of HashTableEntry I assume your iterator is expected to be a ForwardIterator only (not Random, Bidirectional or Backward) So here are few pointers for implementing a ForwardIterator. A. Define the interface. For this look at the usecases. Usecases:[LIST=1] [*]Get iterator to first and last element. (for … | |
Re: Very interesting. Count me in the club who didn't know that private members of one object are accesible to other objects of same type ! I tested on Microsoft Visual Studio 6.0 and Sun Workshop 6.0. It works in both places. Statndard also doesn't seem to say anything to address … | |
Re: First, there is nothing wrong with this code. [code=c] int main() { try { A a_definition; } catch( Exp error ) { std::cout << error.message << endl; } a_definition; // out of scope now... } [/code] a_definition is indeed out of scope at teh place you mention, but so what … | |
Re: First of all, let me say that if you're new to programming you've done a great job with 'neatness' of code. It's so nice to see code with comments. :). Anyway.. A few questions I have before I can answer.. 1. Is it mandatory for u to use C? Can't … | |
Re: [quote=Salem;321393]> Wouldn't you use a public member function to access and modify private member variables? Yes everyone else would. But some people seem to like asking stupid questions like this which subvert the whole idea of using an OO language for data encapsulation. Like somehow knowing that if you could … | |
Re: USUALLY THIS IS NOT A GOOD IDEA. See the problems at the end. Have a conversion operator in your class. [code=c++]class Fraction { public: Fraction(int left = 0, int right = 1); Fraction(Fraction & obj); ~Fraction() { delete fl; } double getFraction() { return *fl; } void operator=(Fraction & obj); … |
The End.