6,741 Posted Topics

Member Avatar for Layla_2401

Lose the static qualifier. extern should be placed on the array in the header file to ensure that it's a declaration. Then include file1.h in both file1.c and file2.c. Make sure that the code to fill the array is called first if you define it in file1.c.

Member Avatar for Narue
0
228
Member Avatar for JoBe

>^^^does that mean the array size is 100 and the first element is equal to 0? An array of size 100 and all elements are initialized to 0. If you privide an initializer list and there aren't enough values, all remaining elements are initialized to the default value T() where …

Member Avatar for Fasola
0
276
Member Avatar for winbatch

In a set, the value is the key. In a map, the key and value are distinct.

Member Avatar for Narue
0
631
Member Avatar for apcxpc

>I've got to implement Prolog in C++ for an assignment. Let me get this straight. You're new to C++ and you've been given an assignment to write a Prolog interpreter in C++? I find that hard to believe. It's easier to believe that you slacked off for most of your …

Member Avatar for apcxpc
0
391
Member Avatar for winbatch

What happens if you try to use a standard container, such as map? Same errors? Or is it specific to the extended containers and algorithms?

Member Avatar for winbatch
0
217
Member Avatar for kingofpain

I've seen excellent attempts to get other people to do homework, but this isn't one of them. Thread locked.

Member Avatar for Narue
0
35
Member Avatar for sscheell2000
Member Avatar for nucleo

>printf( msg ); Bad idea. If msg contains any sequences of characters that look like a format modifier, you'll invoke undefined behavior. Do this instead: [code] printf( "%s", msg ); [/code] >sometimes some of threads freezes Sounds like a deadlock to me. It also sounds like a perfect opportunity to …

Member Avatar for Narue
0
389
Member Avatar for thomasisaac
Member Avatar for pink

Show your attempt. Tell us what you learned while doing it. Otherwise, we'll assume that you want a handout and nobody will help you.

Member Avatar for Narue
0
95
Member Avatar for Qatar

>The base class is point . Inheritance isn't the right solution for point. A shape is not a point. A shape has one or more points, so containment is a better solution. point should be a stand-alone class. I really hate the shape abstraction as a means of introducing inheritance, …

Member Avatar for Narue
0
153
Member Avatar for Fasola

>I need an example of how its done in C++ Inheritance in C++ is far more complicated than Java; it would take me too much space to do it justice. You would be better off getting a good book on the subject. Thinking in C++ covers it well from what …

Member Avatar for wilsonian
0
409
Member Avatar for notbunny

Well, do you understand what the frequency and mode are? The mode can be easily found once you've obtained the frequency, and the frequency is trivial with the standard library: [code] #include <cstddef> #include <iostream> #include <map> #define length(x) (sizeof (x) / sizeof *(x)) int main() { int a[] = …

Member Avatar for notbunny
0
118
Member Avatar for Narue

Daniweb's IRC channel is boring, and it's everybody's fault. The more people that go there, the more fun it will be, so I order everyone to get an IRC client (because Java clients suck) and go to irc.daniweb.com, port 6667 and join #daniweb. This goes double for people who visit …

Member Avatar for nanosani
0
153
Member Avatar for mel2005

Don't post that much code without code tags, and don't bump your thread after just an hour. Both are incredibly rude and don't encourage people to help you.

Member Avatar for marinme
0
279
Member Avatar for Acidburn

>if( first >=0) This is never true since you initialize first to -1. Initialize it to 0 and the vector should work more like you expect.

Member Avatar for Dave Sinkula
0
167
Member Avatar for banbangou

>Anybody can help to explain why "m_line.replace(idx, m_search.size(), replace);" doesn't compile in cygwin Perhaps because replace isn't a valid third argument? How about: [code] m_line.replace(idx, m_search.size(), m_replace); [/code]

Member Avatar for banbangou
0
125
Member Avatar for Ghost

Yes, but not with straight C++. You're looking at operating specific API calls.

Member Avatar for Ghost
0
819
Member Avatar for server_crash

>Would both abstract and static be correct answers? No, abstract is the correct answer. static only means that a nested class doesn't designate an inner class.

Member Avatar for server_crash
0
1K
Member Avatar for bluegoo06

>This is not likely ever to be true. You mean false? I'd say it's highly likely to be true since EOF must be a negative quantity and characters gathered from a narrow stream must fit within an unsigned char. Fortunately, the other half of the condition will cause the loop …

Member Avatar for Dave Sinkula
0
175
Member Avatar for Sukhbir

>what will happen if we free the same memory two times in C Undefined behavior. Anything could happen.

Member Avatar for Narue
0
93
Member Avatar for thlegendkiller

>display teh string "HELLOWORLD" in ascending style Riiight. Care to explain what you mean by "ascending style"? >what does %.*s stand for??? The . is a field width modifier. Any value after it is how many characters of the string should be printed. The * is a placeholder for a …

Member Avatar for Narue
0
345
Member Avatar for Fasola

I answered your question in the original thread that you asked it, but for convenience I'll copy the answer here: >Can you please clarify the difference between Sequential Access Files and Random Access Files? Humor my love for simile. A sequential access file is like traversing a linked list, while …

Member Avatar for Fasola
0
194
Member Avatar for nabil1983
Member Avatar for winbatch

[code] string operator+ ( const string& s, const Dan& d ) { return s + d.toString(); } [/code] Since Dan doesn't have a suitable conversion to std::string, you also would need to provide another operator+ with the commutative operation: [code] string operator+ ( const Dan& d, const string& s ) …

Member Avatar for Narue
0
302
Member Avatar for Fasola

The most common method by far is TCP/IP or UDP using sockets. Unfortunately, that's a rather broad topic. You can get a bunch of good info to get started [url=http://www.ecst.csuchico.edu/~beej/guide/net/]here[/url].

Member Avatar for Narue
0
218
Member Avatar for johnson9000

Lines in blue are the changes I made: [code] [COLOR=Blue]#include <vector>[/COLOR] #include <iostream> [COLOR=Blue]using namespace std;[/COLOR] class Object { private: short data; public: Object(){data = 1;}; }; [COLOR=Blue]typedef Object* pObject;[/COLOR] class Container { private: vector<pObject> v; public: Container(){v.reserve(1);}; void Add_Object(pObject o){v.push_back(o);}; }; int main() { [COLOR=Blue]Container theContainer;[/COLOR] theContainer.Add_Object( new Object() …

Member Avatar for johnson9000
0
165
Member Avatar for Narue

There's a link to list all active users on Daniweb from the forum nexus. It would be nice to also have that feature for each individual forum, or at least a way to sort by forum. Would that be too difficult to implement?

Member Avatar for Dani
0
276
Member Avatar for ikanku15

>What a kind of comparision do we do? It does a lexical comparison using the integral value of a character: [code] int i = 0, j = 0; while ( a[i] == b[j] ) { if ( a[i] == '\0' ) return 0; ++i; ++j; } if ( a[i] < …

Member Avatar for Narue
0
223
Member Avatar for feda

Sorry, but I can't be bothered. Why don't you write it for me then post it in my name? In case that was too subtle for you, I'm basically saying that without proof of effort on your part, nobody is going to help you unless your problem is dead easy, …

Member Avatar for feda
0
75
Member Avatar for wal99d

>Are there any good solution Yes, Dave's solution is a good one. Your code will fail because string literals can't be modified, and strtok modifies the string you pass to it. Changing cmd to an array fixes the problem. Just in case you didn't catch it, remove the parts in …

Member Avatar for wal99d
0
249
Member Avatar for MrNiceGuy82
Member Avatar for wsn

>the instructor told me there are two mistakes in this Design or implementation? Design-wise, the use of integers as position markers is silly, pointers to nodes would make more sense. It also suggests that the list is always in a certain "state" where to get to the front of the …

Member Avatar for wsn
0
132
Member Avatar for haskari

Is this homework? If not, what kind of research did you do before coming here asking for code? If so, why are you asking [b]us[/b] to do it for you? >ohw to open closed thread You ask a moderator to do it for you (preferably me, since I closed it …

Member Avatar for Narue
0
176
Member Avatar for jhdobbins

>First, how do you feel about operator overloading? It's a frivolous feature that isn't really needed, but it sure is a convenient feature when used intelligently. For example, the iostream library certainly makes streams easier to use by overloading operator<< and operator>>. String comparisons are more intuitive by overloading the …

Member Avatar for jhdobbins
0
103
Member Avatar for haskari
Member Avatar for mb1

Your StripVowels is way overkill. At least it would be if it weren't filled with type mismatches and unnecessary member function calls: [code] #include <algorithm> #include <iostream> #include <string> using namespace std; bool is_vowel ( const char c ); void StripVowels ( string& s ); int main() { string s; …

Member Avatar for Narue
0
99
Member Avatar for Auto

>Can the main() call be embedded within a class? You need to make the distinction between a function declaration, a function definition, and a function call. What your example does is declare a member function with the same signature as the global main. However, it's [b]not[/b] the same function as …

Member Avatar for Auto
0
149
Member Avatar for Tyreses

[url=http://www.ecst.csuchico.edu/~beej/guide/net/]Clickie here for the best free tutorial on sockets[/url]. And please don't come back here bitching that it's not C++. The concepts are identical, and free stuff is never exactly what you want.

Member Avatar for Tyreses
0
230
Member Avatar for atrixnet

>Yes but how do I change that? I would think it would be obvious: [code] char [COLOR=Blue]*[/COLOR] getstring (char strquestion[255]) [/code] >I'm sorry? What do you mean? sprintf returns the number of characters printed, not a string of any sort, which is what your use of getstring suggests. You could …

Member Avatar for Narue
0
619
Member Avatar for Narue

The game is simple. Search a forum (preferrably one that you don't visit often) and post a quote from that forum that you find amusing, informative or just plain cool. Use of the search feature is encouraged. Rules: 1) All quotes must include the name of the original poster. 2) …

Member Avatar for nanosani
0
312
Member Avatar for mehdy

>how i can run vc++ 6 program in vc++.net Just a minor nit. "How I can" is a statement, "How can I" is a question. And to answer your statement, if the old project isn't being updated, just create a new project in VC++ .NET and transfer your source files.

Member Avatar for Narue
0
147
Member Avatar for jhdobbins

>Please tell me there is an easier way than this Put your data into a structure, create an array of structure objects, and sort that: [code] struct course { string name; int hours; char gpa; char grades; }; course courses[50]; ... bsort(courses, cnt); [/code] Then you need to change bsort …

Member Avatar for Dave Sinkula
0
800
Member Avatar for Gink

>Microsoft Visual C++... great IDE, very easy to use, but costly... The standard edition is only $99US. Hardly costly unless you're a student with no cash. Though Dev-C++ seems to be a favorite among the freebies.

Member Avatar for Gink
0
361
Member Avatar for paradox814
Member Avatar for nanosani
0
105
Member Avatar for Menohac
Member Avatar for csi_a_m

[code] #include <iostream> using namespace std; int main() { int a[5][5] = { {1, 2, 3, 4, 5}, {6, 7, 8, 9,10}, {11,12,13,14,15}, {16,17,18,19,20}, }; // Row major order for ( int i = 0; i < 5; i++ ) { int sum = 0; for ( int j = …

Member Avatar for csi_a_m
0
194
Member Avatar for nobody
Member Avatar for Narue
0
92
Member Avatar for j.kelly

If the date is invalid you do this: [code] date = NULL; [/code] Then you proceed to do this: [code] return *date; [/code] That would be dereferencing a null pointer, which is illegal and highly likely to crash your program. Of course, that entire function is one big red flag. …

Member Avatar for j.kelly
0
146
Member Avatar for Acidburn

Can you post your code? Preferrably something small that still exhibits the problem.

Member Avatar for Acidburn
0
132

The End.