6,741 Posted Topics
Re: >The interview needs to be by phone Good luck with that. Anyway, why does it need to be by phone when email or public forum is perfectly suitable and more likely to be acceptable to most? | |
Re: You only fill exercise[0]. Perhaps this would work better for you: [code=cplusplus] for (i = 0; i < 5; i++) { cin >> exercise[i]; cout << exercise[i] << endl; } [/code] | |
Re: Let's say you have a row of beers[1] and you're looking at the first one. Oh, your name also happens to be ptr. Nice to meet you Mr. Ptr. Here's the game: You want the first beer, so you try to drink from it. Let's say that to drink from … | |
Re: >Global, static, and local variables were often stored in the stack Kinda sorta. An accurate description (as required by my standard nazi status) is that you essentially have three options: automatic, static, and dynamic. Automatic is pretty much always implemented using a runtime stack, which is why people talk about … | |
![]() | Re: Labels don't introduce a new scope. This error tells you that jumping into the switch can (or does) ignore the definition of the object even though it's still in scope. I'm sure you can imagine what would happen if you try to use an object that doesn't physically exist. A … |
Re: Well, you didn't show any of your tree, so the best I can do is link you to a tutorial I feel is good: [url]http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_bst1.aspx[/url] | |
Re: Post a complete program that exhibits the problem, please. Also post the exact error message rather than summarizing. | |
Re: >I posted a question that I needed help with about 4 hours ago Don't let our usual efficiency fool you. This is a volunteer service, so you should have no expectations about how long it takes to get an answer, or the quality of the answer. >Is it that the … | |
Re: GCC is correct, your other compiler is not. >Can anyone explain the problem? The order of operations for function-like macro parameters (as per section 6.10.3.1 of the C standard) is to identify the parameters, then replace any macro parameters, then substitute the parameters with actual arguments. The order you expected … | |
Re: If you can't fit the value into a long int or a long double (or long long, if your compiler supports), you need some kind of arbitrary length arithmetic type, which isn't native to C++. | |
Re: Count your opening braces and your closing braces. | |
Re: >Why is it a bad practice to use it? Laziness. Most of the time, people who use goto are too lazy to consider all of the alternatives and choose the best solution. They fall back on goto, but because they're lazy, they don't use it wisely and the result is … | |
Re: Let me guess, you don't know anything about C, you've never programmed before (but this app is going to be AWESUM!!!!!) and want someone to do it for you on your state of the art version of Turbo C 1.0. :icon_rolleyes: | |
Re: Did you link with user32.lib as well, or just include windows.h? Headers contain the necessary declarations for your code to compile, but for the code to link, you need the corresponding definitions as well. Those definitions are usually stored in an static object library file, or a dynamically linked library … | |
Re: Check the code snippets section. IIRC, you'll find examples that can be combined to do everything you want. | |
Re: >where will be the temp.txt written to ? Most likely the current working directory >how can we change the written location of the temp.txt ? Change the current working directory, or specify an absolute path rather than a relative path. | |
Re: >Yes it is possible Correct. >but the code will be large enough and not good from good programmers view Um, how do you think printf was written? Granted, cutedipti probably doesn't compare to the quality of programmer that writes the standard library code, but suggesting that the code won't be … | |
Re: >Is there a better way? Yes, design the class hierarchy such that you don't need to know the dynamic type of the object. Perhaps some form of strategy pattern would clean up that selection code. | |
Re: >How do i export integers to another function? Ideally you would import values through parameters and arguments, and export values through the return: [code=cplusplus] #include <iostream> int foo() { return 10; } void bar ( int import ) { std::cout<< import <<'\n'; } int main() { bar ( foo() ); … | |
Re: I've consulted on video game projects, does that count? | |
Re: I'm moving this to the Geeks' Lounge as it really has nothing to do with game development. | |
Re: Unresolved symbol errors typically mean you aren't linking with the correct libraries. Those symbols are all part of the Win32 API, so your project settings for external libraries are probably incorrect. | |
Re: >My output right now is saying everything is out of the language. I'd start with the fact that you aren't actually parsing the given grammar. Consider two examples: 1) The grammar states that a term by itself is a valid expression, but your expression function doesn't implement this behavior. In … | |
Re: >list<Item> l; Perhaps you meant [ICODE]std::list<Item> l;[/ICODE]? | |
Re: [code=cplusplus] template<typename T> LinkedQueue& LinkedQueue::operator=(const LinkedQueue& queue) { ll = queue.ll; return *this; } [/code] You need to be more careful about specifying template parameters: [code=cplusplus] template<typename T> LinkedQueue<T>& LinkedQueue<T>::operator=(const LinkedQueue<T>& queue) { ll = queue.ll; return *this; } [/code] | |
Re: Try it and see. It's not like a simple experiment will take any longer than it took to create this thread. | |
Re: >it's basically okay to write big functions recursive, large functions iterative What if I want to write a large function recursive and a big function iterative? :D | |
Re: >I thought it would return the value of x since x is in both statements and yet it doesnt. Interesting reasoning. The reason it doesn't return x is because a boolean expression will always result in a boolean value (true or false). | |
Re: It's best to think of the preprocessor as a completely different language than C. In particular, #define statements do not generally end with a semicolon because the semicolon is considered to be a part of the replacement text. This is what your compiler sees: [code=c] int mem[64000;]; int frames[6400;]; [/code] … | |
Re: You've found the easiest way to do it. Read each line into a record, break the record up into fields, append the record to an array of records, and sort the array by your chosen field. If you have a lot of records, use a faster sorting algorithm such as … | |
Re: >what is difference between the final binary output of the same program >written in c and written in an assembly if they do exactly the same thing. Hand-crafted assembly written by a skilled assembly programmer will probably be more optimized than the object code produced by a compiler. >if they … | |
Re: >How am I supposed to remember that??? When you use it often enough, remembering becomes simple. In fact, if you program for long enough, you'll actually develop muscle memory for typing out your template and won't have to remember. ;) >If you wouldnt mind could you explain what the includes … | |
Re: The %c specifier doesn't ignore leading whitespace. And for future reference, it's %c, not %ch. %ch looks for a single character and then 'h'. | |
Re: >even if I comment out the push and pop calls it will still display the right numbers Clearly. Your use of the stack is effectively a no-op because you push eax onto the stack, then immediately pop the value off of the stack and back into eax. The state of … | |
Re: Long, or System.Int64. Are you incapable of cracking a book or searching the web? We're not your personal reference, you know, and questions like this are easily answered on one's own. | |
Re: >1. const int* a; (what the difference between const int *a and why pointer need to be const?) Whitespace makes no difference here. [ICODE]const int* a[/ICODE] and [ICODE]const int *a[/ICODE] are identical. The pointer is not const, it points to an object that is const. To make a pointer const, … | |
Re: >I finished the program and it works, but my teacher's very picky about efficiency. Your program is I/O bound. The time it takes for a user to type a number and the time it takes to print the output will vastly overwhelm any processing efficiency. I recommend that you focus … | |
Re: When you use an array name, it's converted to a pointer to the first element. That's why this works: [code=cplusplus] int arr[10]; int *p = arr; [/code] By a rights and purposes, an array shouldn't be compatible with a pointer and the assignment should fail. But because arr is converted … | |
Re: >I'm looking for a very easy to use compiler That's the crux. IDEs are generally more difficult to use because they combine the myriad tools you would be using along with a command line compiler. I'd say that [URL="http://www.codeblocks.org/"]Code::Blocks[/URL] is probably the easiest to get started with. [URL="http://www.microsoft.com/express/vc/"]Visual C++ 2008 … | |
Re: Since you didn't give nearly enough information, or provide even a rudimentary attempt, this is all you get. Here's how a real-world programmer would do it: [code=cplusplus] #include <algorithm> #include <string> std::string s = "hello"; std::reverse ( s.begin(), s.end() ); [/code] | |
Re: >error: cannot convert ‘std::ifstream*’ to ‘char**’ for >argument ‘1’ to ‘__ssize_t getline(char**, size_t*, FILE*)’ That looks like your compiler is trying to call the wrong function. Try prefixing getline with std:: to force name lookup to check the std namespace. | |
Re: I don't want to sound mean, but you should try a different method of study, or perhaps consider that you may not be suited to programming. I've watched you ask questions for months without making any progress at all, and it's kind of depressing. | |
Re: >that's good! I just need to declare it as public It's rather depressing how you latched on to the [I]worst[/I] possible option that stilllearning suggested. | |
Re: If you don't explicitly delete your memory, it doesn't get deleted. >will this become a memory leak for whomever Yes, yes it will. | |
Re: Do you mean you want the values to be variable yet still persistent across runs of the program? | |
Re: strcmp doesn't return true or false, it returns a comparison: <0 - The first string is "smaller" than the second string >0 - The first string is "greater than the second string 0 - The strings are "equal" In your test [ICODE]strcmp(argv[5], "yes") && strcmp(argv[5], "no")[/ICODE], you're saying evaluate to … | |
Re: >fread (&temp,amount*sizeof( *z_array ), 1 ,binaryfile); temp is a float. Read your reference on fread again, double check the actual values you're passing it, and you'll see a problem. | |
Re: >always exits after 2 guesses abd says the guess was correct even if it's wrong Not necessarily. If you enter 10, then 70, you get three guesses. By the look of things, the correct message won't print unless the guess really is correct, but you only ever have one iteration … |
The End.