6,741 Posted Topics

Member Avatar for lappy512

That's implementation dependent. What compiler are you using and on what operating system?

Member Avatar for Tight_Coder_Ex
0
124
Member Avatar for xfruan

Most likely your use of clrscr was frivolous and unnecessary, so it's better not to clear the screen at all. If you really want to do it you can use [url=http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1031963460&id=1043284385]this page[/url] to help you along. But I [b]strongly[/b] suggest that you have a ridiculously logical and good reason for …

Member Avatar for Narue
0
121
Member Avatar for sonaj

Since the user can specify the size of your playing board, you need to create a matrix dynamically: [code] #include <stdio.h> #include <stdlib.h> int main(void) { int i, j, size; char **board; printf("Enter the board size: "); if (scanf("%d", &size) != 1) { fprintf(stderr, "Invalid input\n"); return EXIT_FAILURE; } /* …

Member Avatar for kshama002
0
246
Member Avatar for Iamhere

@Iamhere: Please don't start another thread asking the same question a mere day later. Doing so discourages volunteers from addressing your problem. @Everyone else: Please direct any replies to the following thread: [thread=19839]Please can somebody help[/thread].

Member Avatar for Narue
0
174
Member Avatar for kloony

>so if I had done some other things later on in my program Once freed, the memory is no longer yours. That means that in theory, another process could allocate the memory immediately after you're done freeing it and overwrite the values you had stored there before printf is called …

Member Avatar for kloony
0
481
Member Avatar for SyLk

>Passing a reference of an object thorugh value is passing by reference. No, the reference is passed by value, so it's [b]not[/b] passing by reference. Google for "java pass reference", it's a common misunderstanding.

Member Avatar for Narue
0
584
Member Avatar for ashjoy

Get a newer compiler? I've heard talk about WinBGI, but I don't know anything about it. That might be a good start for a google search.

Member Avatar for Narue
0
67
Member Avatar for Almost a GURU

Your compiler is new enough, you should be using the string class rather than C-style strings. That would sidestep the problem you're having entirely: [code] #include <string> std::string key; std::string msg; std::cout<<"Enter the key: "; if (!std::getline(std::cin, key)) { // Handle input error } std::cout<<"Enter the message: "; if (!std::getline(std::cin, …

Member Avatar for Almost a GURU
0
85
Member Avatar for arikeri

>Hope This is Clear enough Not really. Explaining how you're going to do something is irrelevant if we don't know what it will be used for. Knowing the end result is a key element in determining how to approach a problem. >Iam not able to decide what data structures to …

Member Avatar for Dave Sinkula
0
134
Member Avatar for Iamhere
Member Avatar for Iamhere
0
177
Member Avatar for degoden

Depth first searches are easy to classify. All you need to do is break down the algorithm into recursive calls and actual work done on the downstream, then use the ordering to classify the algorithm. Here's your function without all of the fluff: [code] if (t->left != NULL) n++; if …

Member Avatar for Narue
0
101
Member Avatar for roscioeak@direc

First, please use [url=http://www.daniweb.com/techtalkforums/misc.php?do=bbcode#code]code tags[/url] whenever posting code. Otherwise any formatting is lost and it's much harder to read. Second, you still haven't shown us how time24 is defined. That's very important if we're going to help you solve your problem. Feel free to post the contents of d_time24.h (using …

Member Avatar for Narue
0
132
Member Avatar for letmec
Member Avatar for Acidburn

Member functions can be simply called in one of two ways. If the function is declared as static then you call it using the scope resolution operator and the [b]name[/b] of the class: [code] class C { public: static void foo(); }; // ... C::foo(); [/code] If the member function …

Member Avatar for Narue
1
181
Member Avatar for firion

Unfortunately, graphics.h is a rather old library, so tutorials covering it are sparse. Your best bet would be to search google for tutorials that mention graphics.h. Turbo C++ might also offer example code in the help files.

Member Avatar for vegaseat
0
103
Member Avatar for evilsilver

>load.open(i); Open requires a C-style string, so you'll need to do a conversion at some point: [code] char filename[20]; sprintf(filename, "%d", i); load.open(filename); [/code] To use sprintf you need to include <cstdio>, though the C-style solution isn't necessarily the best. Another alternative uses C++ strings and stringstreams: [code] ostringstream oss; …

Member Avatar for evilsilver
0
78
Member Avatar for TOG85

>Also with VC++ That happens everywhere. cin's >> operator determines how to accept input by the type of its arguments. If you say you'll enter a number but you actually enter a character (which is an invalid number), it only makes sense that the call should fail.

Member Avatar for Narue
0
90
Member Avatar for arikeri

>How do I solve this problem? Think squiggly: [code] for (l=0;l<=5;l++){ for (k=l,++k;k<=5;k++){cout<<"\n"<<i<<"\t"<<j<<"\n"; } } [/code] :)

Member Avatar for Narue
0
70
Member Avatar for Ghost

>cannot resolve symbol: constructor cml (int[],int[],java.lang.String)in class cml at line 439 You're calling a constructor that you haven't defined. In the code posted, only a constructor call to cml with zero arguments is allowed.

Member Avatar for server_crash
0
261
Member Avatar for arikeri

Basically you're looking at a fancy table lookup. Build a table of Gray codes for however many bits you're comparing and then look for two adjacent numbers in the list that match the codes in your table. Repeat until your computer chokes and dies. One easy way to build a …

Member Avatar for arikeri
0
212
Member Avatar for SyLk
Member Avatar for SyLk
0
490
Member Avatar for dal4488

>Anyone else see it? Yes. Think if it as a word problem. Read your instructor's comments and follow along with the code. You'll see what he's talking about.

Member Avatar for Narue
0
124
Member Avatar for roscioeak@direc

>apptQ.push(apptQ.front + apptList.pop); but that would only work with a stack right? No, that wouldn't ever work because front is a member function, pop is a member function, and apptList isn't even an object, it's an array. Assuming time24 has a single argument constructor, you could do something similar to …

Member Avatar for Narue
0
137
Member Avatar for walljoshua

>I am getting a cannot find symbol-variable member. That's because it can't find a definition for the Membership class. I also get an error concerning ArrayList because you neglected to show us what imports you're doing.

Member Avatar for Narue
0
106
Member Avatar for Dark_Omen

ReadLine returns a string, and you can use the Parse method of int to convert a string representing a valid integer into an int value: [code] using System; class main { public static void Main() { Console.Write("Enter an integer: "); string s = Console.ReadLine(); try { int n = int.Parse(s); …

Member Avatar for Dark_Omen
0
127
Member Avatar for tchampion22

Do you know how to do it on paper? If not then there's no way you can tell the computer how to do it. Understand the problem first, then try your hand at solving it. If (only then) you get stuck, we'll be happy to give you hints.

Member Avatar for maj0nes
0
664
Member Avatar for dal4488

>cout << "Amount Due = $" ,, amountDue << endl; You forgot to hit the shift key here, it should be: [code] cout << "Amount Due = $" << amountDue << endl; [/code] [code] if (minutes > 50) amountDue = rServiceCost + ((minutes - 50) * rPerMinuteCharge); cout << "Account …

Member Avatar for Narue
0
159
Member Avatar for loki73

>But how do you use them? Particularly in overloading operators situations. All of the friend functions in the following code are auxiliary functions. [code] #include <iostream> using namespace std; class Integer { public: Integer(int init): data(init) {} public: friend ostream& operator<<(ostream& out, const Integer& i); friend istream& operator>>(istream& in, Integer& …

Member Avatar for Narue
0
131
Member Avatar for Asif_NSU

>i dont know which one to follow Try them all, starting with the simplest. >i dont know if that's the correct way to do it Why? It sounds reasonable enough to me when that's one of the two established ways to find the canonical form of a boolean expression. >I …

Member Avatar for Asif_NSU
0
750
Member Avatar for syphyr_0707

Well, my first inclination for such a toy program would be: [code] #include <algorithm> #include <iostream> #include <string> using namespace std; int main() { string line; cout<<"Enter a line of text: "; getline(cin, line); int n = count(line.begin(), line.end(), ' '); cout<<"There are "<< n + 1 <<" words"<<endl; } …

Member Avatar for syphyr_0707
0
99
Member Avatar for evilsilver

When working with C-style strings, the first thing you need to remember is to have enough memory. If you're going to tack a string onto another string, make sure that the destination string has enough memory to hold both strings [b]plus[/b] one null character. You can concatenate strings with the …

Member Avatar for Narue
0
182
Member Avatar for dal4488

>int arithmeticOperator; This should be: [code] char arithmeticOperator; [/code] The reason is that cin>> is smart enough to tell what type of variable you're passing it. If arithmeticOperator is an int then entering any character other than a valid digit will cause the input stream to fail. [code] case +: …

Member Avatar for Narue
0
323
Member Avatar for sutty8303

>using namespace std; must be placed right after your include statement This isn't a requirement. >and should not be included inside of a function. Why not? It's perfectly legal and because using statements follow scoping rules, it has practical uses. >float circle_area(float &radius); Since your function is defined before main, …

Member Avatar for Index
0
124
Member Avatar for evilsilver

You haven't left yourself any options, so you're SOL unless you grow a brain and join the 21st century. Sure, you could downgrade to an OS that supports DOS programs, but that's really a step in the wrong direction.

Member Avatar for 1o0oBhP
0
123
Member Avatar for JoBe

Play around with this and see what you can come up with: [code] #include <iostream> using namespace std; #define bit(x) (1UL << (x)) int main() { unsigned int x = 0; x = 1; // 00000001 cout<< x <<endl; x |= bit(1) | 1; // 00000011 cout<< x <<endl; x …

Member Avatar for Fasola
0
443
Member Avatar for Foxtildawn

>i keep getting error messages when i try to build my program Maybe you should try reading them instead of running here every time a build fails. And you still haven't bothered to post shorter code.

Member Avatar for Narue
0
165
Member Avatar for Crazyike

All of the parts of a for loop are optional. For example, to write an infinite loop you might do this: [code] for ( ; ; ) { /* Stuff */ } [/code] Converting a while loop to a for loop is trivial with that little tidbit. Of course, there …

Member Avatar for Narue
0
94
Member Avatar for ianwaters
Member Avatar for tenoran

To find the largest value in a list, save the first value and walk through the list, saving the largest: [code] T largest = list[0]; for (int i = 1; i < list.size(); i++) { if (list[i] > largest) largest = list[i]; } cout<<"The largest value is "<< largest <<endl; …

Member Avatar for tenoran
0
135
Member Avatar for Foxtildawn

One of these characters doesn't belong. Can you find it? [code] void ItemType::PayMe(bool okay)[COLOR=Red][SIZE=7];[/SIZE][/COLOR] { if(!okay) total = total + rank * 1000; else total = total+ 50; } [/code] Sadly, I don't have your other header, and I'm too lazy to go through all the code you posted. So …

Member Avatar for Narue
0
166
Member Avatar for compshooter

>Do you need to put the ; after the last }? No. >Do you need to put a return statement before the last }? In C, yes. In pre-standard C++, yes. In standard C++, no, 0 will be returned automagically. Whether you choose to or not for standard C++ is …

Member Avatar for vegaseat
0
153
Member Avatar for ap39769

> I am a new member of the free Unix sdf.lonestar.org. And what is that? A shell account? Most shell accounts will restrict your use of the system (such as compiling and running custom programs) to protect against malicious use.

Member Avatar for Narue
0
74
Member Avatar for evilsilver

It depends heavily on how your game works. For the most part, all you need to do is save relevant information about the player such as stats, items, and location. Then you can rebuild the current game state upon load.

Member Avatar for vegaseat
0
187
Member Avatar for SquirrelProdigy

Sure. What if you want to work with a file as well as standard input and output?

Member Avatar for Narue
0
256
Member Avatar for Narue

Just for fun, I threw this together by modifying and adding to a simple language definition posted here recently. Since everyone hates me, I'll give you a chance to snipe at my first draft. :D The code is long enough to be an uncomfortable post, so I'll attach a zip …

Member Avatar for Narue
0
546
Member Avatar for pmorones

>what PRACTICAL use would all of this serve once you get it working? Each set could be a collection of vertices in a graph used for routing packets through a network in the most efficient manner possible.

Member Avatar for Fasola
0
172
Member Avatar for maizen

>You can't compare strings the way you do. Sure you can. The string class overloads the relational operators. Though <string> needs to be included. >the file never opens correctly Try this: [code] #include <iostream> #include <fstream> #include <cassert> #include <string> using namespace std; int main() { int numberOfWords; string fileName; …

Member Avatar for Dave Sinkula
0
349
Member Avatar for hopeolicious

>your code is crap No argument there. >haven you ever consider using header files and making it into objects Using classes and objects isn't always the optimum solution, and for small programs, it may not be practical to use multiple files. I disagree with both of your reasons for calling …

Member Avatar for Narue
0
129
Member Avatar for Foxtildawn

string is in the std namespace, so you need to qualify each use of that name in one of three ways: [code] // Per-use qualification std::string a; std::string b; [/code] [code] // using declaration using std::string; string a; string b; [/code] [code] // using directive using namespace std; string a; …

Member Avatar for Narue
0
79
Member Avatar for flory

>I do have difficulties to understand functions in c++. What don't you understand? If you're more specific, we'll be in a better position to help you. >read a book you stipid person If you're going to insult someone, at least use correct spelling and grammar.

Member Avatar for Pmaster
1
198

The End.