6,741 Posted Topics
Re: >I have a question on an assignment that has me confused. And confused you should be, because the question is ambiguous. >The question is how many times does the following loop execute? The real question is what language is that? If it's pseudocode that follows C++ rules, the loop will … | |
Re: >hope this helps u gettin final code... >I have a soln for solving armstrong numbers I take solace in the fact that people who give away homework solutions usually come from the shallow end of the programmer pool. :icon_rolleyes: | |
Re: I believe GCC comes with Mac OSX. There's the Xcode IDE as well, but I'm not sure what compiler it uses. Unless you're using one of those Mac Minis, you should already have a compiler installed and ready to go. >If i compile it on the Mac, will it work … | |
Re: I'm seeing a lot of the same code from supposedly different people. | |
Re: What exactly are you looking for a tutorial on? A tutorial on Visual C++ Express Edition is somewhat of a vague request. You'd be better off buying a book that covers Visual Studio if you want a detailed tutorial on how to use the application. | |
Re: The problem is that you calculate the final grade when printing the table, but don't calculate the letter grade until the next loop. At that point the final grade is set to whatever the final grade of the last student was. You need to merge those two loops: [code=cplusplus] cout<<"Student … | |
Re: >Everything without using pointers and strings By "string" you mean the std::string class? Assuming you can store the characters for a word somewhere (like an array or a vector), it's fairly easy to follow those rules. However, without knowing what level of C++ you're at, I'll probably end up giving … | |
Re: You can have my hat if you want. It doesn't go with the rest of my wardrobe. | |
| |
Re: >printf("Enter Number :"); You should call [ICODE]fflush ( stdout )[/ICODE] after this. The stream buffer is only guaranteed to be flushed when it's full (which you can't portably determine), when a newline is printed (which you aren't doing for this prompt), or when fflush is called. If stdout isn't flushed … | |
Re: >I have searched anywhere and ask many people but I couldnt find out the way to do it. Did you bother to ask the teacher that's forcing you to do it? Teachers tend not to ask you to do something that you have absolutely no knowledge of. | |
Re: >int n; >float a[n]; Not only is initializing an array size with an uninitialized variable hideously broken, array sizes in C++ have to be compile-time constants, so what you're trying to do won't work anyway. You need to either handle the memory manually with new[] and delete[], or use a … | |
Re: >can a class allow a friend method of a friend class to use it's protected or private members Just because you're my friend doesn't mean your other friends are also my friends. >can a friend method of a derived class use base class's protected members If you're my child, your … | |
Re: You don't change a file in-place, you either read the file into memory and make your changes before truncating the file and rewriting it, or you use a temporary file so that only one record is in memory at a time. | |
Re: Can you provide an input to this function that produces an incorrect result? [edit] Also include what the correct result should be. [/edit] | |
Re: C++ doesn't have a long long type. You're relying on compiler extensions. | |
Re: My hobbies are rock climbing, tennis, creative writing, programming, and martial arts. I particularly enjoy the rush of physical exertion and being able to do things that other people can't. When I'm bouldering a brick wall or running through a kata and people stare at me dumbfounded, it's a good … | |
Re: >I read that Borland 2007 was easier to use than VC++. Do you have an opinion on this ? I don't think it is, but I can see how some people would feel that way. Visual Studio is a feature rich development environment. Borland doesn't throw everything in your face … | |
Re: >but what is the purpose of the retrieval operation? I would assume it's a search member function that gives you the node at a particular index or with a particular value. | |
Re: >I dislike the idea of diddling with the input stream like that. Any time you go back and forth in a track that [i]should[/i] be one-way, it feels wrong. My problem is that ungetc is restricted enough to be frustrating and flexible enough to be virtually useless. However, there are … | |
Re: >It will only display the second student I enter but not the first. It will only ever display the last record entered. You're using the temporary variables to print your table instead of the contents of the vector. | |
Re: >What should I declard it as. int, perhaps? And initialize it to 0? i is a counter that starts at the beginning of the string and looks for the null character. Are you really trying to say that you don't understand how an array index works? | |
Re: Let's use some multiple choice logic, shall we? 1) The likelihood of (d) is minimal, otherwise there would be similar choices. 2) (c) can be ruled out because (a) and (b) both have the same value for ch. This logic rules the options down to deciding between .2 or .0. | |
Re: When you say --x, x is decremented by one before being used in the expression. Likewise, ++x increments x by one before using it in the expression. x++ or x-- will perform the increment or decrement after using the value in the expression. [code=cplusplus] int x = 0; int y; … | |
Re: >i have already been told im an idiot by other people on other forums! That wasn't very nice of them. >If you can see anything obviously wrong here, please help! I see something suspicious, though it may or may not be wrong. >meanAndMedianAddr(copyArray, size, &mean, &median); mean and median are … | |
Re: >I suppose you could do this, just to see who's awake You're a cruel, cruel man, Salem. | |
Re: >Microsuck Do you think you can do better? If not, you have no right to throw around insults. >but it seems like you have to learn a whole language when dealing with Visual Studio! You probably just haven't done much Windows programming, or much programming at all, come to think … | |
Re: >I'm slightly confused as to why the unsigned char makes a difference? toupper takes an integer parameter, but that integer is required to be either EOF or in the range of unsigned char. Because sent holds values that you can't be sure fit in that range, a cast forces the … | |
Re: [url=http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_sorting.aspx]This link[/url] is a vain attempt to help you, even though I'm reasonably sure you're beyond help at this point. >Please help me, this homework is for tomorrow So...you have an assignment due tomorrow on sorting a linked list and you have exactly [b]zero[/b] code that even attempts to sort … | |
Re: Reading from a file is just like reading from the keyboard. Let's say you want to read the first two records, you would do it from cin like this (if you were me): [code=cplusplus] std::string month; // Read the month if ( getline ( std::cin, month ) ) { std::cout<< … | |
Re: And? Do you have a question or are you just posting trivial yet sloppy code to waste everyone's time? I see a disturbing trend in your posts. Maybe you should acquire a compiler and run these programs yourself. | |
Re: Rule 1) A pointer isn't an array. Just because you say int *x doesn't mean you can immediately use x as if it were an array. You need to allocate memory to it first. Rule 2) main returns int. Rule 3) Don't try to use the file positioning functions until … | |
Re: >Also plan to use class in lieu of struct. That changes the semantics. class and struct are similar, but not synonymous. | |
Re: >sorry i used the old thread; >anyways. Somehow I don't believe that you're sorry at all. | |
Re: >How can i see the assembly produced by the compiler{if it is possible}? You can add a switch to most compilers that tell them to produce assembly output. >Where does the compiler makes a better job than the programmer? Unless you're a good assembly programmer (and in some cases a … | |
Re: >How do you clear the console screen without any system-compatibility issues? Start by altering reality such that standard C++ recognizes a "screen" and a "console" in a convenient way. >but this is for a computer engineering course I'm impressed. Most programming courses actually take the opposite stance when it comes … | |
Re: >but I haven't been able to find any compilers for it. You didn't look very hard, did you? A search for "C++ compiler" brings up a number of immediate hits, and a simple search of this forum would give you all of the popular ones. But no, you had to … | |
Re: >It's like saying strlen("hello") which obviously ain't gonna work. And why is that? ![]() | |
Re: >I never said memcpy() wasn't standard. The implication was there. Just think of it as adding to your answer rather than correcting you. >If not, you may very well be playing with fire to try reading >(or writing) past the end of memory you have not allocated. I don't even … | |
Re: I can think of a few definitions for "trace". Can you be more specific? | |
Re: >Is it possible for me to use "FILE" pointer concepts in my programming. It really depends on what kind of embedded program you're writing. If this is a freestanding implementation (not hosted by an OS), you're not guaranteed to have the stdio library at all. In that case if you … | |
Re: Even the worst book on C++ will will cover such topics as arrays, and we don't particularly enjoy explaining things that are covered in great detail in *every* available reference. For a quick overview, try surfing over to wikipedia and search for arrays. | |
Re: >> Second. the sizeof requires parentheses. >Wrong again, it only needs () when it's a variable name, not a type name. It's the other way around. sizeof requires parentheses with a type name, but not a variable name. >1. Arrays in C/C++ are managed by having a variable that points … | |
Re: >I am strictly a cash person! Credit cards are evil, an easy way to trap stupid people! I think that makes you a stupid person. You have to build good credit if you want to buy a car, or a house, or rent an apartment. An easy way to do … | |
Re: >after i write this program there's error i don't know why ? It's customary to post the error as well as the code. Most of us can tell you what's wrong by reading the error, but if we only have the code we have to read it carefully or compile … | |
Re: This isn't a free homework service. You're supposed to write the code yourself, and we can help you make it work. But don't expect freebies. | |
Re: >there's a problem with compiling this code Of course, it could also be the syntax errors. >so how am i supposed to change class vector in order to make it compile? Maybe I'm missing something, but if you want to change the contents of your object, you shouldn't have declared … | |
I've been writing my own implementation of stdio.h whenever I get a few spare minutes recently. Nothing fancy or thorough, and without wide character support, it's hardly conforming. But I was looking at one of my intermediate versions of printf and could only marvel at how ugly it was. So … | |
Re: [code] void quicksort(int theArray[], int first, int last){ int pivotIndex; if(first < last){ //create the partition: S1, pivot, S2 partition(theArray, first, last, pivotIndex); } } [/code] Hmm, methinks you're missing something. ;) Why don't you try starting out with a working recursive quicksort (I posted a code snippet that's a … |
The End.