6,741 Posted Topics
Re: First figure out how to count how many divisors are evenly divisible for single number. Once you have that, the solution presents itself as a variation of finding the maximum value in a set: [code] int main() { int most = 1; int val = 1; for ( int i … | |
Re: >I wrote what I could in my program but now I'm stuck. You don't have any problems that a good book on C++ and a compiler wouldn't solve. >double main() I don't see this often. Usually the return type is either void or not present. I'll say this once, very … | |
Re: >can anyone please tell me whether it is possible to make graphics work in borland c++? Yes, it's possible and there are several ways of going about it. | |
Re: >just posting to bring it back up. Please don't do this, it's very rude. >If anyone can conjure up a HUGE project for me to do based on this tutorial Write a command line text editor such as [url=http://www.rt.com/man/ed.1.html]ed[/url]. | |
Re: Can you be more specific as to what formulae you're talking about? Otherwise I'll just direct you to the mathematics section of your local bookstore. | |
Re: >while (Number1 >> 0) { "While the number is [b]much[/b] greater than zero"? :D;) A bitwise shift doesn't appear to be something you would want in this program. | |
Re: When posting relatively long code compared to the tiny toy programs usually posted, it's best to include the exact error messages you get, and the comments on the lines that cause them if applicable. Here's your code with the requisite changes made to compile and link as C: [code] #include … | |
Re: >Why am i getting ints as the output I want doubles??? I have no idea, but I'll admit that I didn't look very hard. Your code relies on files that I don't have, so proper testing is not possible. Why not strip the code down by hardcoding input values rather … | |
Re: If both Process ID and Process Time have a common subset of operations that you can use from the array then you can have them as derived classes: [code] abstract class process_thingie { public abstract String get_thingie(); } class process_id extends process_thingie { private String id; public process_id ( String … | |
Re: You only work with strings explicitly in getNumerator and getDenominator, so those should be your first targets for debugging. I notice that you make a [b]lot[/b] of assumptions about the strings in question. indexOf can return -1, which would be a bad thing, and the input could be malformed, which … | |
Re: >how can I fix it to where it reads 16 bytes at a time. Without looking at the code: [code] char buffer[17]; ... fgets ( buffer, sizeof buffer, in ); [/code] | |
Re: You can do it with templates, but it really isn't a better approach complexity-wise. The common method is to use the preprocessor with <climits>: [code] #include <climits> #include <iostream> #if INT_MAX != 2147483647 # error integers must be 32 bits long #endif int main ( void ) { std::cout<< INT_MAX … | |
Re: >A hash table is basically a linked list of linked lists An array of linked lists you mean. If the table is implemented as a linked list then the time required to traverse to the proper hash index would dominate search times and it's not much of an improvement. If … | |
Re: >but am not understanding it.... Don't try to, it's wrong and will most likely give you an access violation at run-time. Dare I ask what book you got the code from? | |
Re: >I know this is not good code, but i was wondering They're both undefined, so your question can't be answered. Undefined means anything can happen, from nothing at all to the increased spin rate of any proton related to the change in state that is effected by your use of … | |
Re: All object memory is allocated at either load time or run time, there really is no compile time allocation (technically there is, but not in the way that you're thinking) from an implementation standpoint. Can you be more specific as to what objects you're talking about when you say "function"? | |
Re: >passing arg 1 of `fgets' from incompatible pointer type fgets expects a pointer to char. You pass it a pointer to int because buffer is defined as an array of int. Change buffer to be an array of char and the warning will go away. >should this be in my … | |
Re: _gcvt is a Visual Studio function. sprintf should work fine provided you consider limit as the number of significant precision digits. >but the output looks rather crude to the perfectionist. How appropriately vague. Care to be more specific? | |
Re: >undefined referrence to 'WinMain@16' You're compiling as a Win32 application, not a console application. But either way you would get an error as you haven't defined main at all, whether it be the C++ main or the Win32 API WinMain. | |
Re: >void run(); This is a function declaration, not a call. You need to call dvd's run member function: [code] int main() // void main is ALWAYS wrong! { char option; do { dvd.run(); // Get option // ... } while ( option != 'n' ); } [/code] | |
Re: >but it's not showing the 5th position. Your search only looks for the first occurance. To find subsequent matches, you need to continue the search until the end because you don't know how many matching items there are in the list: [code] public class Main { public static void main … | |
Re: >Please i want the code of the function which could get the serial number of the Hard-disk of any computer I want a paycheck every two weeks, but nobody just gives one to me without any effort on my part, even when I say "please". | |
Re: >what is the difference between structured & oop's ? One is structured and the other is object oriented. Do you want to ask a more specific question? | |
Re: >Pliz give me ideas. Ideas for what? What are you trying to do that you need help with? I'll assume that because '3' is not the scan code for Esc, you don't know what to test for. Try 27, if I remember correctly, that's Esc. If you search the boards … | |
Re: Yes, it is possible. It isn't terribly difficult either if you're familiar with socket programming. | |
Re: >could any 1 reply plz............ I was going to help you, until I saw that you bumped your thread before 30 minutes had passed. That's incredibly rude. Try this: [Useful suggestion removed because you don't deserve it. Figure the solution out on your own] | |
Re: >IS this compiler specific or defined by the standard?? Only the interface is standard. How new and delete operate internally is up to the implementation. However, memory managers tend to be similar and you can make certain assumptions about the relationship between malloc/free and new/delete at the lowest level without … | |
Re: >I've been programming for sometime now and one thing I've never had to do is any sort of "debugging". You're incredibly lucky then to have never made any kind of mistake in your programs. Debugging is the process of removing an error whether it be compile-time, run-time, link-time, or a … | |
Re: Compare and contrast: >double findarea (double,double); >d=findarea(a,b); >double findarea (double q,double r,double s) { Be sure to take careful note that the declaration takes two arguments and the definition takes three. C++ treats these as two unique functions that are overloaded to have the same name, therefore the linker is … | |
Re: [code] #include <iostream> #include <string> #include <typeinfo> using namespace std; template <typename T> string typeof ( T arg ) { return typeid ( arg ).name(); } int main() { char ch = 'a'; cout<< typeof ( ch ) <<endl; } [/code] | |
Re: Never use gets. It's impossible to make gets safe. All you need to do is match declarations: [code] char strings[N][LENGTH]; ... void f ( char strings[N][LENGTH], int size ); [/code] Then it's just a matter of counting from 0 to size - 1 and using [b]fgets[/b] to fill strings[i] with … | |
Re: >so basically i just need a formula to figure out leap years If the following is true, the year is a leap year: year % 4 == 0 && year % 100 != 0 || year % 400 == 0. The test for modulo 4000 really isn't necessary because we … | |
Re: Here is some pseudocode to swap two items in an array indexed by i and j. TYPE is whatever type of data are in the array. [code] TYPE save = a[i]; a[i] = a[j]; a[j] = save; [/code] | |
Re: Using loops, draw the following shapes: [code] ***** ***** ***** ***** ***** [/code] [code] ***** * * * * * * ***** [/code] [code] * ** *** **** ***** [/code] [code] ***** **** *** ** * [/code] [code] * *** ***** ******* ********* [/code] | |
Re: I much prefer this one: [code] #include <cstring> static int is_valid_function_name(const char *function_name_string){ return std::strpbrk(function_name_string, "?/\\:*<>\"") == NULL; } [/code] ;) By the way, qualifiying a global name as static to give it internal linkage is a deprecated feature. If this was the original intent of the function--as opposed to … | |
Re: Why not use the array as a sort of existence table. For example, you would have an array of boolean designating the number of seats: [code] boolean occupied[] = new boolean[N]; [/code] Now for each index i, i + 1 is the seat number. When the seat is occupied, set … | |
Re: >Let me know if im on the right track. You're spot on, well done. :) | |
Re: >but toString methode is just in class Car not in Class carTable. So define it for carTable. | |
Re: >Its just this darn mod operator is so stubborn. When working with money, it's best to use integers because floating-point has accuracy issues. However, if you really want to use floating-point, the standard library supports the fmod function. fmod will perform modulus on two floating-point values. | |
Re: >i need afull c++ programm of game called "pebble chess" Have fun writing it. :) | |
Re: >How about this.... How about not? By "improving" the code, you've broken it. Before, the Person class was a POD type and thus could be legally treated as a sequence of bytes (as stream.read does). And while performing a binary read into a class or struct type is immensely stupid … | |
Re: >How do I get the highlighted lines below to center above the **************** Print a bunch of spaces before Hours: [code] cout<<" "<< Hours <<":"<< Mins <<":"<< Secs <<endl; [/code] >And why won't the program give me the total seconds after I entered the formula Amazing. Getting a decent question … | |
Re: You have too many global variables for me to guess accurately what the problem is, but my first suggestion would be to make sure that your strings are terminated with a null character ('\0'). | |
Re: >if anyone can help please do so. I don't see a problem. Open the Java source file, read it line by line, and do a string search for the appropriate keywords. The result is a good start for your solution; you can refine the search from there on the off … | |
Re: Strange values typically mean that you've forgotten to initialize a variable. This is the bug you should be searching for using print statements and a debugger if you have one. | |
Re: >so it's hard to critique A critique is not difficult at all: "Your code is crap, post something that actually uses C--not whatever it is you think is C--and we'll help." Simple. :) | |
Re: >I have been trying to get this for the past 2 weeks !! Do you have any code after these two weeks? >1)Delete all the occurunces of x; Removing an item from an array is an involved procedure. You need to shift all items after it to fill in the … | |
Re: >Can anybody PLEASE provide me with some code No. I remember being grateful to people who gave me solutions when I was learning, but now I wish they hadn't because it hurt me more than it helped. That's why I'm a hard ass when it comes to solving your problems … | |
Re: You can only have one main function. And if you bother to listen to people when they tell you to stop using iostream.h, you won't have to look at the warnings complaining about deprecated headers. | |
Re: >can someone explain to me what does below code do?? It simulates the Alt+Enter keystroke that puts an application into full screen mode. |
The End.