506 Posted Topics

Member Avatar for JadedTortoise

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](). …

Member Avatar for WaltP
0
186
Member Avatar for roby4eldiablo

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 …

Member Avatar for thekashyap
0
69
Member Avatar for saqib

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" …

Member Avatar for saqib
1
119
Member Avatar for gamodg

- 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 …

Member Avatar for GreenDay2001
0
76
Member Avatar for tikal777

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 …

Member Avatar for tikal777
0
113
Member Avatar for arunprabhakar

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 …

Member Avatar for Ancient Dragon
0
798
Member Avatar for ch1ck3n

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 …

Member Avatar for ch1ck3n
0
80
Member Avatar for potato_bum

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().

Member Avatar for thekashyap
0
1K
Member Avatar for shrikant telkar

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.

Member Avatar for thekashyap
0
59
Member Avatar for roby4eldiablo

Does cygwin have any kinda support for signal handling? If yes d'u know which is the file that defines teh signals... ?

Member Avatar for roby4eldiablo
0
98
Member Avatar for Duki

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 ) …

Member Avatar for Duki
0
4K
Member Avatar for taineechan

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 …

Member Avatar for taineechan
0
155
Member Avatar for Savage221
Member Avatar for thekashyap
0
91
Member Avatar for uswatun
Member Avatar for xdfear

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 …

Member Avatar for WaltP
0
55
Member Avatar for rodkay

[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 …

Member Avatar for rodkay
0
103
Member Avatar for darylharkin

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...

Member Avatar for darylharkin
0
79
Member Avatar for hlnren
Member Avatar for keya_datta
0
113
Member Avatar for san_fran_crisko

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 …

Member Avatar for san_fran_crisko
0
147
Member Avatar for radhikaDS
Member Avatar for geetha_sg

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 …

Member Avatar for thekashyap
0
83
Member Avatar for jorritgoddijn
Member Avatar for hanna_f15
Member Avatar for jnabeel

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 …

Member Avatar for jnabeel
0
293
Member Avatar for mzd12111

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 …

Member Avatar for mzd12111
0
125
Member Avatar for livingsword

[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 …

Member Avatar for livingsword
0
413
Member Avatar for Matt Tacular

It's a bit strang, but you never know the compilers... Try: rectangle theRect2; Instead of: rectangle theRect2[B]()[/B];

Member Avatar for kishore5001
0
133
Member Avatar for alaaharb

Sure. [URL="http://www.daniweb.com/techtalkforums/announcement8-2.html"]Here it is[/URL].

Member Avatar for thekashyap
0
123
Member Avatar for jnabeel

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..

Member Avatar for Salem
0
83
Member Avatar for nelly12

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 …

Member Avatar for thekashyap
0
112
Member Avatar for gabs

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 …

Member Avatar for thekashyap
0
131
Member Avatar for Marauder_Pilot

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];"

Member Avatar for underjack
0
147
Member Avatar for MattTobin

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 …

Member Avatar for MattTobin
0
111
Member Avatar for nayrb

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. :)

Member Avatar for thekashyap
0
98
Member Avatar for nayrb

>> 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 …

Member Avatar for thekashyap
0
974
Member Avatar for Salem

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.. :)

Member Avatar for happygeek
0
147
Member Avatar for arfmal

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.. !

Member Avatar for thekashyap
0
248
Member Avatar for daddeh
Member Avatar for WaltP
0
102
Member Avatar for chubbywubba

You really gotta learn and use "functions".. For the problem at hand try [URL="http://astyle.sourceforge.net"]AStyle[/URL] if it helps..

Member Avatar for thekashyap
0
129
Member Avatar for fightfox06

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; …

Member Avatar for WaltP
0
1K
Member Avatar for thekashyap

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 …

0
330
Member Avatar for livingsword

[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]

Member Avatar for John A
0
95
Member Avatar for MattEvans

>> 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 …

Member Avatar for thekashyap
0
119
Member Avatar for MiloTN

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 …

Member Avatar for dwks
0
132
Member Avatar for developer4321

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 …

Member Avatar for thekashyap
1
1K
Member Avatar for MattEvans

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 …

Member Avatar for thekashyap
0
89
Member Avatar for Darkmeerkat

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 …

Member Avatar for John A
0
135
Member Avatar for MiloTN

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 …

Member Avatar for MiloTN
0
181
Member Avatar for virsa

[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 …

Member Avatar for Laiq Ahmed
0
141
Member Avatar for degamer106

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); …

Member Avatar for thekashyap
0
80

The End.