6,741 Posted Topics

Member Avatar for PeterX

>How EOF(end of file ) works? EOF is simply a macro designating a negative value. It doesn't have to be -1. You can signal end-of-file from the command line with a control character, usually a combination of ctrl+z for Windows systems or ctrl+d for POSIX systems. >while((c=getChar()) !=EOF) Do you …

Member Avatar for N1GHTS
0
258
Member Avatar for Firestone

>Is there another way to pause the program with C, without using system("PAUSE"); Sure. Don't run your program in an IDE that isn't smart enough to keep the window open. Run it from the command prompt.

Member Avatar for Narue
0
2K
Member Avatar for tomtetlaw

[B]>does strcat modify the source paramater at all?[/B] No, it's a pointer to const char. This strikes me more as a fencepost error with your loop index, where it starts at CON_LINES rather than CON_LINES-1.

Member Avatar for Narue
0
173
Member Avatar for chun0216

[B]>Is there anyway I can optimize the first one to something that could make my program faster?[/B] Your program is slow because your code sucks. Don't make it suck more by trying to micro-optimize.

Member Avatar for kes166
0
110
Member Avatar for marygloria

Those aren't questions, they're coding assignments. You also didn't ask any questions about those assignments, so we're generally going to assume you want someone to do it for you. That's cheating, cheating is not encouraged on Daniweb, and if it's what you want, you're welcome to piss off. Otherwise, here's …

Member Avatar for Narue
0
254
Member Avatar for Rez11

Not only is it possible, it's recommended that you use the std::string class instead of C-style strings. I imagine you've tried this already and gotten an error, which prompted you to ask an overly generic question when posting your code and asking a specific question will get your problem solved …

Member Avatar for Rez11
0
170
Member Avatar for bdv

I'd use a while loop. But since you can use any loop to simulate the behavior of any other loop, it's really personal preference.

Member Avatar for CrazyDieter
0
84
Member Avatar for sakthi@daniweb

[B]>then why there is no error message like >"too many parameters are not allowed"[/B] While a compiler [i]could[/i] warn you at build time about a different number of actual arguments than the format string suggests, it's more complicated than you might think. [B]>do you mean that 1 act as parameter …

Member Avatar for planetmirchi
0
170
Member Avatar for applepomme

Well, for starters you used the wrong constructor. Change the definition of wanted_string to this: [code] string wanted_string(original_string, 0, 7); [/code] If that still doesn't work, post a complete program so we can test it.

Member Avatar for Narue
0
130
Member Avatar for Xorlium
Member Avatar for hsquared
Member Avatar for ronicasingh

The interview is there to determine if you're suitable for the job. If you can't answer the questions to their satisfaction, you have no business working at that company. That's my advice, now if you want something more specific, ask a more specific question.

Member Avatar for Akill10
0
173
Member Avatar for praky

[B]>I want to know the differences in between two?[/B] That's a tough comparison. Can you be a little more specific? [B]>also is this code equivalent[/B] No, the C code has two bugs (an uninitialized FILE pointer, and using char instead of int for the return value of fgetc). The C++ …

Member Avatar for brandonrunyon
0
428
Member Avatar for glenn612991

Separate [i]how[/i]? Do you want them in two different arrays? Do you want to print them on two different lines? Do you want the negative numbers to sing and the positive numbers to dance? Be specific, or don't complain when nobody helps you.

Member Avatar for Vllinator
0
2K
Member Avatar for sujathaarsid

Sounds like homework. Why don't you implement all of those algorithms and add logic to count the iterations? It's not hard. I'll even give you a [URL="http://www.eternallyconfuzzled.com/tuts/algorithms/jsw_tut_sorting.aspx"]link[/URL] to a page with code for all of the algorithms you specified.

Member Avatar for Adak
0
90
Member Avatar for pulpers
Re: Java

[URL="http://www.mindview.net/Books/TIJ/"]Thinking in Java[/URL]

Member Avatar for Narue
0
27
Member Avatar for CPT

[URL="http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_linklist.aspx"]This tutorial[/URL] might be helpful.

Member Avatar for Ancient Dragon
0
158
Member Avatar for low_coder
Member Avatar for low_coder
0
121
Member Avatar for johnray31

Provided you supply either an overloaded operator<, or a comparison predicate in the map constructor, you can use any user-defined type as the key.

Member Avatar for Narue
0
101
Member Avatar for solitaryy
Member Avatar for dkolcun

Floating-point values are imprecise by nature. Trying to compare them for equality is fraught with peril. ;) A fuzzy comparison is usually the best approach. As long as the difference of the two values is less than a certain epsilon, you're good: [code] #include <cmath> #include <cstdlib> #include <iostream> #include …

Member Avatar for dkolcun
0
113
Member Avatar for Rahul.menon
Member Avatar for Ancient Dragon
0
136
Member Avatar for Dani

[B]>Do you read the DaniWeb news stories?[/B] No. [B]>If not ... what about them doesn't interest you?[/B] There are better sites for news, in my opinion. I treat Daniweb as a forum, nothing more.

Member Avatar for Ancient Dragon
0
662
Member Avatar for fire_

It's the second one. Your first snippet is [i]two[/i] if statements, one with and one without an else clause.

Member Avatar for Fbody
0
90
Member Avatar for vbx_wx
Member Avatar for jakesee

If I understand your question correctly, the compiler is not allowed to reorder struct/class members between access specifiers. You can make the order unspecified like so: [code] struct Vertex { public: Vector3 p; public: Vector3 n; public: Vector3 c; } [/code]

Member Avatar for jakesee
0
161
Member Avatar for cezarjont

[B]>is there any difference between the construction of max heap and min heap??[/B] The only difference is the ordering of your data. In a min heap, the smallest elements have priority, and in a max heap the largest elements have priority.

Member Avatar for Narue
0
6K
Member Avatar for challarao

Check your man pages, strrev might actually be present. If not, it's a trivial function to implement for your personal library: [code] #include <string.h> #define SWAP(T, a, b) \ do { T save = (a); (a) = (b); (b) = save; } while (0) char *reverse_string(char *s) { size_t len …

Member Avatar for sree_ec
1
4K
Member Avatar for Obsidian_496

The code isn't C++, it's Java. [edit] I'd recommend [URL="http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_bst1.aspx"]this site[/URL] for your binary search tree needs. It's largely in C, but the conversion is much easier than from Java. [/edit]

Member Avatar for Narue
0
105
Member Avatar for kuen

[B]>up[/B] Bumping is rude. Now I'll likely ignore all of your subsequent threads.

Member Avatar for kuen
0
117
Member Avatar for kloony

How is that strange? On Windows you didn't touch memory that would cause a critical error, on Unix you did. It means your code is broken. Look for uninitialized pointers and out of bound array accesses. Those are the prime culprits for a seg fault.

Member Avatar for creeps
0
199
Member Avatar for harikrishna439
Re: gets

[B]>I'm getting a warning message while compiling.[/B] Judging by your thread title, the warning is something along the lines of "gets is unsafe". The usual recommendation is to prefer fgets because it allows one to provide a limit to the buffer whereas gets will just happily read until a newline …

Member Avatar for Narue
0
102
Member Avatar for rowanmck
Member Avatar for hurbano

Okay, what do you have so far? It sounds like you're working toward a chained hash table implementation, because the array of linked lists for exact matches is a common collision resolution strategy in hash tables.

Member Avatar for hurbano
0
83
Member Avatar for GBoyle

[B]>In a contact object I store a pointer, which may be for a BCorp or a BPrsn, so I cast it as a (double*).[/B] I can't begin to fathom why you're using double* instead of void* for a safe transient pointer type. Could you explain your reasoning here?

Member Avatar for GBoyle
0
149
Member Avatar for kuchick32

There's no operator for a factorial in C++, you need to perform the multiplications manually. You have the right idea though, now it's just a matter of details. Here are a couple of things to consider down the road: [list] [*]This factorial function accepts a signed integer argument, which means …

Member Avatar for Narue
0
101
Member Avatar for Duki

[B]>When I see a thread in C++, and the last poster is "Ancient Dragon" >or "Narue", I just don't bother even opening the thread.[/B] Sounds like a poor strategy if your goal is self-improvement. I try to read all threads that seem remotely interesting ("Gimme teh codez!" are not, by …

Member Avatar for ~s.o.s~
0
172
Member Avatar for embooglement

[B]>I was just wondering what other people's opinions were.[/B] I wouldn't bother with any kind of marker in the string. The caller clearly knows what radix they want to generate, so generate the string and let them add a prefix (or suffix) if they so desire.

Member Avatar for mrnutty
0
137
Member Avatar for challarao

[B]>What is the use of writing an integer before d or any formal specifiers.[/B] It gives you more control over the output than the defaults. You can override field width, padding, justification, precision, sign display, and whatnot. In this case, you're changing the field width. For example, if you're writing …

Member Avatar for creeps
0
101
Member Avatar for creeps

[B]>char str[31], ch;[/B] Let's start with this common error. EOF is guaranteed to be a negative quantity, but char may be unsigned. getc returns int for a reason, and that reason is to guarantee that EOF is representable regardless of the signedness of vanilla char. [B]>while((ch = getc(fp)) != '\n')[/B] …

Member Avatar for Narue
0
158
Member Avatar for Mehh

In other words, you don't know anything about C++ and just randomly pasted the contents of a tutorial into your text editor. What a surprise that it doesn't compile. :icon_rolleyes:

Member Avatar for Ancient Dragon
-1
174
Member Avatar for rowanmck
Member Avatar for SaiBalaji

Homework is designed to help you solidify your knowledge. If someone else does it for you, you don't learn anything except how to be helpless. So try it first, and if you have problems post your code so someone can help you correct the problems.

Member Avatar for Narue
0
260
Member Avatar for priyanka.js28

[B]>I just (wrongly) assumed that all compilers would compile simple increments the same[/B] As with many compiler specifics, it's not quite that simple. Depending on the target processor, different instructions may be deemed more efficient. So you'll see compilers favoring for example add over inc, or lea over both add …

Member Avatar for SaiBalaji
0
425
Member Avatar for chandrut

[URL="http://www.google.com/search?btnG=1&pws=0&q=how+to+connect+C%2B%2B+to+Database......"]Clicky[/URL].

Member Avatar for Ancient Dragon
0
119
Member Avatar for Micko

[B]>but its has its own merits...[/B] There are no merits to gets. [B]>say, the ease of accepting strings...[/B] I've argued this point with authors before (Dan Gookin is one such example), and have yet to hear a sufficiently good explanation of how [iCODE]fgets(s, n, stdin)[/iCODE] is so hard that it …

Member Avatar for Narue
1
140
Member Avatar for Hawkpath

To create an array of objects without initialization, the object type must have a default constructor. The rule in C++ is that a default constructor is generated for you if you don't explicitly define [i]any[/i] constructor explicitly. Your class has a three parameter constructor, so no default constructor is generated …

Member Avatar for Hawkpath
0
116
Member Avatar for vbx_wx
Member Avatar for cogitoergosum18

For starters, operation is a double when it should be a char. You also have a rogue semicolon in your final else that ensures the quotient output will always occur.

Member Avatar for Takeshi91k
0
211
Member Avatar for kz07

[B]>Can anyone help me on how to display my infix notation with parentheses?[/B] It's simple enough, just print your parens at the operator level for sub-expressions you want to wrap (you probably want to exclude unary operators): [code] template <class Item> void infix(exp_tree_node<Item>* root) { if (root != NULL) { …

Member Avatar for Narue
0
1K

The End.