1,118 Posted Topics
Re: What he means is don't use [inlinecode]cin >> myvar;[/inlinecode] alongside [inlinecode]cin.get( mystring );[/inlinecode] The problem comes because doing so breaks the user's input model. When you ask for something, the user types an answer and presses ENTER. The [B]get()[/B] method returns the string entered and tosses the ENTER away. The … | |
Re: That does sound odd. Can you post: 1. an example of the file 2. examples of what you are seeing in windows and in linux 3. the code you are using A cue file is a text file, no? Why are you using fread() instead of something like fgets()? | |
Re: Data structures are central to programming. (A C++ class is a data structure.) What level class is it? If it is lower than your C++ class then you might be able to skip it, but if it is only 100 or less points lower then you should consider it. All … | |
Re: An [B][I]overloaded[/I][/B] function is a function that shares its name with one or more other functions, but which has a different parameter list. The compiler chooses which function is desired based upon the arguments used. An [B][I]overridden[/I][/B] function is a method in a descendant class that has a different definition … | |
Re: User supplied file names must be either absolute or relative to the application. If the file starts with '/' then it must be absolute. Otherwise, it is relative. Just tack it on to the end of the current working directory name, then collapse instances of "./" and "../". You didn't … | |
Re: Yes, your comment is absolutely right. Placing something at the beginning of the line will absolutely cause anything else on the line to be shifted rightward. Since your lines have fixed spaces fore and aft of each card, why not add a couple of spaces to the "header" line that … | |
Re: You need to pull out your textbook and look at some sample programs. Watch your syntax. Whenever a professor says "hint" that's a good place to start. I see you have one 2D array for the card values. You still need a 2D array for whether or not the card … | |
Re: Er, you misunderstand. We think it is the GIF that is faulty, not your code. | |
Re: Actually, you are doing things the Right Way. Five stars for you for using your head. Things are only temporary if you don't plan to use them long. In C++, you can pass things around easily enough and extend their life beyond normal even. [I]Local variables[/I] only live as long … | |
Re: This is a math problem. You want to separate a number into hundreds. 141251 / 100 = 1412 R 51 and 1412 / 100 = 14 R 12 and 14 / 100 = 0 R 14 The C++ remainder operator is [B]%[/B]. Hope this helps. | |
Re: According to [URL="http://msdn2.microsoft.com/en-us/library/ms646302.aspx"]MSDN[/URL]: "This function is useful for input idle detection. However, GetLastInputInfo does not provide system-wide user input information across all running sessions. Rather, GetLastInputInfo provides session-specific user input information for only the session that invoked the function." Even if that were not so, you are trying to do … | |
Re: You most certainly [I]can[/I] return arrays from functions. Here are two ways to solve your problem. [code=Delphi] program u; {$APPTYPE CONSOLE} uses SysUtils; type tPerson = record name: string; age: integer; end; tPeople = array of tPerson; var people: tPeople; //procedure getPeople( var result: tPeople ); // Method 1 function … | |
Re: Use the [B]stringstream[/B] class: [code=C++] #include <iostream> #include <sstream> using namespace std; int main() { stringstream ss; string user_input_string; int user_input_int; cout << "Please enter a word and a whole number: "; cin >> user_input_string >> user_input_int; cin.ignore( 10000 ); ss << "The word is \"" << user_input_string << "\" … | |
Re: If you don't want the same random numbers over and over again, at the very beginning of your program, call the [B]randomize[/B] procedure. [code=Delphi] begin randomize; // init number generator from system clock ... end. [/code] As for the range, the problem is purely mathematical. If you have a list … | |
Re: If you don't set [B]min_val[/B] and [B]max_val[/B] to [I]something[/I], it will be some random number to start --which may be lower or higher than any value in your array. So, if your array were [inlinecode]3 5 97 -2 12[/inlinecode] but [B]min_val[/B] were -349762, you'd have a problem. Both values [I]must[/I] … | |
Re: That's not a circular list, by the way, it is just a regular, forward-only linked list. What you've got there won't compile. When the compiler starts spitting out errors, look at the [I]first[/I] error and the line number it says. Go to that line and fix that error then try … | |
Re: Er, before anything else, you really need to watch your I/O. Don't mix C++ and C. Find every [inlinecode]getch()[/inlinecode] (non-standard [I]evil![/I]) and replace it with [inlinecode]cin.get();[/inlinecode]. Find every [inlinecode]gets(s);[/inlinecode] and replace it with [inlinecode]getline( cin, s );[/inlinecode]. Also, I know everyone teaches and tutorials and etc. this, but try not … | |
Re: The DJGPP is a 16-bit DOS compiler, and as such, will not likely keep up with the most recent C++ standards. Either get [URL="http://www.cygwin.com/"]Cygwin[/URL], which is a small Unix environment running under windows --it includes the most recent version of the GCC (gcc and g++ and a few other languages), … | |
Re: Don't forget that you'll have to [B]free()[/B] the array when you are done with it. [code=C] int *array_without_doubles = remove_doubles( array_with_doubles ); print_array( array_without_doubles ); free( array_without_doubles ); [/code] Good luck. | |
Re: All these little things are important, but I think you need to spend more time thinking about how you are going to solve the problem. The computer is too stupid to do it, so you have to figure it out yourself first. I say this all the time but I … | |
Re: SIGSEGV is a memory access violation --meaning that you tried to read (or write, but in your case read) memory that doesn't belong to you. The problem lies in lines 23 and 25. The condition at 23 is blissfully ignored by the loop at 25, which will continue until you … | |
Re: You need to read up on how to [I]declare[/I] a function and how to [I]call[/I] a function. The function you are trying to use is [I]declared[/I] as: [inlinecode]bool hasaletter( string, char );[/inlinecode] To [I]use[/I] it: [inlinecode]if (hasaletter( "1024x768", 'x' )) cout << "It sure does...\n";[/inlinecode] Hope this helps. | |
Re: While all true, I think your input paradigm is broken. [color=green][B]how you do it matters[/B][/color] Whenever you ask for input from the user what you expect him (or her) to do is type some number of characters and press the ENTER key. That's what [inlinecode]getline( cin, s );[/inlinecode] is for. … | |
Re: A quick re-org to help: [code=C] #include<stdio.h> #include<stdlib.h> #include<string.h> // typedefs don't belong inside functions (not usually, anyway...) typedef struct { int room_num; char room_name[80]; char desc[1000]; int num_links; char direction1[6]; int dest1; char direction2[6]; int dest2; } roomStruct; // Functions need complete types void readRoom ( roomStruct rooms[] ); … | |
Re: 1. [B]n[/B] is the number of elements in the array, where [B]k[/B] is 0, 1, 2, ..., n-1. 2. There is no need to calculate the average inside the loop. Move that stuff outside. 3. Don't forget to set [B]total[/B] to zero first, otherwise you'll just have some random number. … | |
Re: No Pascal compiler is case-sensitive. Pascal is explicitly case-[I]in[/I]sensitive. | |
Re: [url]http://www.daniweb.com/forums/thread95939.html[/url] You really should do your own work. | |
Re: Sed can do it easily. You'll have to get a little familiar with some simple regular expressions. [URL="http://www.grymoire.com/Unix/Sed.html#uh-8"]Here[/URL]'s a page with all kinds of useful information. Hope this helps. | |
Re: [quote]Is there anyway that you can convert the '\n' in windows which is 2bytes to the '\n' 1byte so that the linux could read it?[/quote] Sure. There is a little Unix utility called [B]dos2unix[/B]. It is found on most *nix systems. To do it in code, just set your output … | |
Re: MPLAB SIM is another proprietary, created for a textbook, simulated processor/language. I don't have access to it. Your best bet is to go get help from your professor. I don't think the code tags here understand assembly. I've tried a lot of different variations and none work... Good luck. | |
Re: In OSX just open a command-line window and type [inlinecode]gcc[/inlinecode] or [inlinecode]g++[/inlinecode] to use the compiler. For example, if you have a program source file "palindrome.cpp" then type [inlinecode]g++ palindrome.cpp -o palindrome[/inlinecode] to compile the program. Type [inlinecode]palindrome[/inlinecode] to run the program. You must, of course, be in the same … | |
Re: Perhaps you meant to post in the C forum? (This is C++.) Think about what the program is supposed to do, and [I]write down[/I] a sort of "how to" to get it done: 1. get an integer from the user 2. get another integer from the user 3. get yet … | |
Re: No one here is going to give you code to do your homework. You need to think about the problem some bit more than you have so far, post [I]all[/I] the code you've got and any compiler errors or i/o errors, and then we'll help you fix it. | |
Re: You are going to have to write a global hook and use [B]SetWindowsHookEx[/B]. The procedure that does it will need to be compiled into a DLL (a regular application process is not permitted to use global hooks). Your application can then use the DLL to install the hook and remove … | |
Re: (Thanks Ancient Dragon). In order to check whether an ASCII number is uppercase or lowercase you must decide whether it is greater-than (for lowercase) or less-than (for uppercase) a specific number. You must figure out what that number is. Pay attention on line 22: you test for equality when you … | |
Re: Step by step. 1. Don't fflush(). There is no need and you shouldn't be mixing C and C++ I/O anyway. 2. You are mis-indexing the string: [inlinecode]01234[/inlinecode] [inlinecode]7+i3[/inlinecode] Hence, line[1] == '+' and line[4] == '\0'. BTW, [B]i[/B] never reaches 4 if your input is only four characters long. 3. … | |
Re: How do you compare if two registers are equal in assembly? | |
Re: Why are you using [inlinecode]getline( cin, ... );[/inlinecode]? Don't. Also, your output doesn't quite match the required output... but otherwise everything works fine. Hope this helps. | |
Re: No. I think it is a Solaris-specific extension. Do you think you will need to read or write files larger than 2GB? | |
Re: You are trying to do something like this: [code] for (int i = 0; i < 12; i++) { ... } if (i < 12) ... [/code] The variable [B]i[/B] is only supposed to exist inside the [B]for[/B] loop. The compiler is complaining about your using it outside the loop. | |
Re: I'm not sure exactly what you are trying to do. What exactly do you mean by "moves"? By "object" do you mean a raster color run (a horizontal line of the same color)? What is the purpose of doing this? The ppm format is as horribly inefficient as pbm, the … | |
Re: I think he understands that. In use, however, there is no semantic difference. | |
Re: What about [color=green][B]'till[/B][/color] (for [I]until[/I]) and [color=green][B]nothin'[/B][/color]? If those are also valid then your condition might easily be simply to check if the apostrophe is adjacent to a letter on [I]either[/I] the left [I]or[/I] the right. You are testing each character as you read it, so you will need two … | |
Re: The -- and ++ operators are initially confusing. They are unique to C and C++. What [inlinecode]--a[/inlinecode] means is "make [B]a[/B] = [B]a[/B] - 1 [I]before[/I] you do anything else." Same with [inlinecode]++a[/inlinecode]: [B]a[/B] is modified [I]first[/I]. The [inlinecode]a--[/inlinecode] means "make [B]a[/B] = [B]a[/B] -1 [I]after[/I] you do everything else." … | |
Re: "A" is a string. 'A' is a char. code is a char. Hope this helps. | |
Re: A [B][I]handle[/I][/B] is a number used by Microsoft Windows to keep track of resources (like windows and memory and files, etc.). It has nothing to do with C++. So, if you know the handle of something you can call Win API functions that do something with the resource. To execute … | |
Re: 1. Yes. 2. No. Is this related to the other post you made? Word is not very good at reading all properly-formatted RTF. It likes and understands its own peculiar brand best, and can put-up with simple stuff from, say, wordpad and the like. | |
Re: Somewhere, either in your code or in some library you are using, there is a reference to a function or a variable named 'hasp_login'. The linker can't find it. As for fixing it, can you give a little more information about where you are using it? If you didn't declare … | |
Re: You've got an [I]off-by-one[/I] error. The elements of your array are numbered 0..299. | |
Re: Your professor has done an extraordinary job of giving you concrete information to work with. Just take it one step at a time. Look through the functions he has asked you to write and pick the one you think will be easiest. Do it first. Work from easiest to hardest … |
The End.