118 Posted Topics
Re: well you have found the fibonaci series of numbers with a formula if you place this code into a function to find the fibonaci numbers. Here are two approaches: 1 - write a function that stores all of the fibonaci numbers between a lower and upper limit. this would best … | |
Re: One point that I thought I ought to bring up is that if you have a non integer number such as a decimal you can still find the digits but the stop condition is tricky so while [CODE] int i(142), n(10); int remainder = i%10; i = (i - remainder) … | |
Re: There are a few problems with your code first off it is a good idea to work out the logic and method you want on paper first because I suspect that the book method has resulted in you using a method that has confused you a little log10(1) == 0 … | |
Re: Even if you call the system time to do it every 30 minutes requires a trigger device and as such requires some method of checking when the time changes. If you have an external program that sends a message this will still in effect be slowing down the running of … | |
Re: Random numbers need to use srand( ) otherwise you get the same number each time there are a few posts on this and a quick search will show you some demo code you should get the system time and call srand(time); | |
Re: What is it that you want the system to do when [CODE] #tiered test a 005 b 04 a 5 b 3 a 0005 b 5 #no spaces between number and letter y 000a y 00091 #spaces b 5 abc b 5 abcd b 5 abc [/CODE] ? As I … | |
Re: Assuming that your code was showing multiple files including the same file indirectly by adding the preprocessor line to the top of all of your .h files [CODE] #pragma once [/CODE] you can ensure that no single file includes the same file twice. | |
Re: [QUOTE=Fbody;1131574]It's difficult for me to explain, I'll try to, but perhaps someone else can explain better. [/QUOTE] ditto :) When you say: [icode]int x;[/icode] or [icode]alpha my_alpha[/icode] The computer has to create the space in memory that it needs to store all of the information about the variable. So for … | |
Hi I have what at first seemed to be a very simpe problem: I have a Microsoft Package that requires me to use nmake to make a lib file. I am unfamiliar with make files as I use visio and XP. Now I had to move somethings due to restricted … | |
Re: [QUOTE=wolfkrug;1130769]Wow yeah that fixed it. Thanks, now I need to figure out why that works.[/QUOTE] I am probably missing something but your while loop on line 17 is this the logic you want? if you hold at say 70 and the computer rolls a 1 doesn't that mean that you … | |
Re: [QUOTE=jeffmt1234;1130324]oh, the little cout's here and there were just me debugging... just to see where things were hanging up at..[/QUOTE] Why not build a tree class something like: [CODE] #include <vector> class tree { public: tree(); tree (*parent); add_child(tree * new_child); set_parent(tree * parent); tree * get_parent(); std::vector<tree *> get_children(); … | |
Re: [QUOTE=jonsca;1130407]main should always return an int, not be void. [/QUOTE] Why? It compiles to valid code, The extra return 0 is just more code to maintain. SLEEPYBUG: There are some general things that help when writing code and it is best to start early: give your functions meaningful names A(); … | |
Re: At first glance is a float enough precision for the accuracy you need? Do you need double unless you are seing a separate number 15 I suspect that the file is being chopped as you want but you need a double. If these are being stored from floats to be … | |
Re: You can make your code more readable by [CODE] if(c >= 'a' && c <= 'z') { //lower case } else if(c >= 'A' && c <= 'Z' { } [/CODE] You can also do things like char diff('A'); diff -= 'a'; to get the 32 number | |
Re: [QUOTE=Dewey1040;1129231]I wrote a program to compare two text files character by character and its not working probably an easy thing im just not seeing. [code=c++] for( int i = 0; !ifs2.eof(); i++ ){ getline( ifs2, s2 ); if( !ifs1.eof() ){ getline( ifs1, s1 ); c1 = s1[i]; c2 = s2[i]; … | |
Re: Minimum memory and speed is always a compromise log10 is an ugly way of solving this with possibly fewer steps unfortunately math.h only has double and float versions so [CODE] #include <math.h> while(--size) { ++Counts[ int( log10( float(*num) ) ) ]; ++num; } [/CODE] This code uses fewer temp variables … | |
Re: This looks at lot like a template code that someone is asking you to modify without you having understood the parts. I am not quite sure why you would want to output a double quote in real life as it is not a useful piece of information but you want … | |
Re: I suspect that this kind of question is just homework so perhaps I should not be answering it. Binary = base 2 there is a function that will tell you the remainder of any number called modulo and use the % sign so 5%3 = 2; as an integer representation … | |
Re: I cannot test any script at the moment as I am in the middle of a long run and looking for thngs to do before it finishes. The ascii charcter charts show that 130 should be é so the char(130) is working the -126 a char is 8 bits and … | |
Re: 2 approaches to consider: 1st assuming that you have a list of questions that are unique in something like a std::vector<std::string> questions there are two approaches I would recommend #2 #1 Shuffle the questions so that they are in a random order You can use a method suggest by the … | |
Re: This is a question about tolerance of accuracy and it does depend on the application that you are using as a rough rule of thumb I use the 0.000001; if I am looking for a stop condition but you can go smaller if you have the ratios Consider: (a*d == … | |
Re: if you are using c++ there are useful containers in the stl standard template library if you read up about strings you will find that a lot of the work has been done for you but beware replace() doesn't do what you would expect //pseudo code to put buffer in … | |
I have a std::string (char *, std::string::size_t ) constructor failing and I am not sure why. For my small test file there was no problem, but when using ifstream::read() with an unsigned int sz of 1Gb (1073741824) (I think that I used a pos_type 1st time) and the resulting char* … | |
Re: [QUOTE=khevz09;1124562]My only problem is the spacing..... to make it right.... i need to make it inverted pyramid pattern... like this: this is my code and only thing that wrong is the spacing before the rows... [/QUOTE] If I have understood you correctly you have an unwanted space at the start … | |
I am having problems with the new operator() specifically within std::string I appear to have hit a memory limit in visual studio. Ideally I would like someone to help me find one of the following solutions: 1 - Can I access the memory in a very big file directly without … | |
Re: I have not directly had to change over from c to c++ for a large number of files but there are couple of things to perhaps clarify in your questions. I think that what you have is effectively a file called "functions.h" In a functions.c file you have defined several … | |
Re: [QUOTE=justsawyer;1118410]How would I make or find a spellcheck for wordpad and I don't mean like all spellchecker I mean like a built in spellcheck like in word were you just press F7 and bam no haveing a whole other program up so how would I even start to make that?[/QUOTE] … | |
Re: [QUOTE=miteigi-san;1121801]the opening of the file is in another function that calls that function~ and I dont think using the array will be convenient because the words will consume too much memory.. [/QUOTE] For 50 words as described memory should not be even close to being an issue I have a … |