118 Posted Topics

Member Avatar for aswin cp

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 …

Member Avatar for mrnutty
0
1K
Member Avatar for bori02082009

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) …

Member Avatar for abdelhakeem
0
163
Member Avatar for pearle

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 …

Member Avatar for tetron
0
122
Member Avatar for suncica2222

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 …

Member Avatar for suncica2222
0
147
Member Avatar for tikoti

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);

Member Avatar for jephthah
0
471
Member Avatar for Narue

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 …

Member Avatar for dusktreader
7
2K
Member Avatar for wwsoft

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.

Member Avatar for wwsoft
0
145
Member Avatar for srinath3

[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 …

Member Avatar for srinath3
0
165
Member Avatar for tetron

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 …

Member Avatar for mitrmkar
0
520
Member Avatar for wolfkrug

[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 …

Member Avatar for tetron
0
161
Member Avatar for jeffmt1234

[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(); …

Member Avatar for jeffmt1234
0
404
Member Avatar for sleepybug

[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(); …

Member Avatar for jonsca
0
102
Member Avatar for nocloud

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 …

Member Avatar for Frederick2
0
591
Member Avatar for invisi

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

Member Avatar for WaltP
0
123
Member Avatar for Dewey1040

[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]; …

Member Avatar for WaltP
0
177
Member Avatar for BarakH

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 …

Member Avatar for tetron
1
109
Member Avatar for iamfabian

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 …

Member Avatar for tetron
0
401
Member Avatar for Dhanika

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 …

Member Avatar for Dhanika
0
2K
Member Avatar for Begjinner

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 …

Member Avatar for Duoas
0
134
Member Avatar for I0adidas0I

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 …

Member Avatar for peter_budo
0
158
Member Avatar for OmarOthman

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 == …

Member Avatar for WaltP
0
163
Member Avatar for chinnaedu

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 …

Member Avatar for tetron
0
110
Member Avatar for tetron

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* …

Member Avatar for tetron
0
208
Member Avatar for khevz09

[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 …

Member Avatar for tetron
0
83
Member Avatar for tetron

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 …

Member Avatar for Ancient Dragon
0
1K
Member Avatar for Democles

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 …

Member Avatar for Ancient Dragon
0
171
Member Avatar for justsawyer

[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] …

Member Avatar for tetron
0
142
Member Avatar for miteigi-san

[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 …

Member Avatar for tetron
0
541