118 Posted Topics
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 … |
The End.