166 Posted Topics

Member Avatar for insanely_sane

MSVC, code::blocks, all the rest of the normal IDEs, etc. Pretty much just google "C++ IDE", and take your pick at random if you have no preference. I use MSVC 2008.

Member Avatar for mike_2000_17
0
194
Member Avatar for BarnacleBoy

Float is to short What double is to long A float stores 1/2 the bits of a double A double is a 64bit number, a float is 32bits like an int, but some of its storage is used for the decimal point. Use double, although with a number as small …

Member Avatar for vijayan121
0
216
Member Avatar for geekykitty
Member Avatar for Beancounter5

Make a function that blocks until year_seconds seconds have passed, where year_seconds is a variable you have flow control of, such that you can increase or decrease it at different phases of the evolution simulator you are creating. Naturally, the process will typically finish in microseconds, so if you want …

Member Avatar for mike_2000_17
0
104
Member Avatar for aviavyne

[CODE] using namespace std; // don't const double Pi = 3.1415; // why not 3.1416 (3.14159) [/CODE] [CODE] int main() { master z01; double r; std::cout << "Please Enter A Radius \n"; std::cin >> r; z01.setvalue(r); // setvalue is really ambiguous, consider changing function name std::cout << "The area is: …

Member Avatar for Unimportant
0
110
Member Avatar for dmm1983

So do you have a specific question or are you asking for me to do your homework for you?

Member Avatar for Unimportant
0
181
Member Avatar for Tiny_trixer

[CODE] default: "Illegal option!"; // Did you forget std::cout? This obviously won't compile [/CODE]

Member Avatar for Tiny_trixer
0
118
Member Avatar for nickx522

[CODE] int hours(minutes/60); if( (minutes%60) > 0 ) ++hours; [/CODE] Divide minutes by 60 for the number of hours, the conversion to the "int" type will floor the value (drop any decimal amount) The % (modulus) operator returns a remainder of division. If your number of minutes is not divisible …

Member Avatar for nickx522
0
164
Member Avatar for Mona..

What scope of reverse? Each line? Each character? Start by saving each line in an array of std::string, then iterate backward through that array. If it has to be by character, you could add a reverse printing of each std::string by the same method. If you want more help, at …

Member Avatar for Mona..
0
132
Member Avatar for krazyito65
Member Avatar for realproskater

Edit: My bad, I just re-read the code. A fibonacci sequence starts with 0 for a reason, you omitted it. Also, you print starting from a[2] (fN=2) [CODE] cout << a[0] << "\n" << a[1] << "\n"; for(fN=2;fN<=i;++fN) { // note that because fN starts at 2, the range from …

Member Avatar for kes166
0
135
Member Avatar for ashu1

...seriously? At least make the smallest attempt to accomplish your goal. Write at least 100 lines of code and return only after that, with a specific question about why you are stuck. How do you expect to learn if you're spoonfed your answers from start to finish? Besides, programming is …

Member Avatar for Unimportant
-2
89
Member Avatar for JCal1108

[CODE] int* getElements(int num) { // don't return "int" unless you cast to pointer later int *ptr; // this is a pointer to int ptr = new int[num]; // it is still a pointer to int, since the new array is of ints //Enter 5 numbers. std::cout << "Enter " …

Member Avatar for Unimportant
0
120
Member Avatar for raheel_88

Modify your for loop according to the values of n you want to iterate. for numbers ranging from 10 to 10000: [CODE] for( i=10; i<10001; ++i ) { } [/CODE] would work just fine, so what's missing? [CODE] for( i=start; i<end+1; ++i ) { } [/CODE] just accept start and …

Member Avatar for Unimportant
0
834
Member Avatar for Nathaniel10

q0[0] is an address + 0x00 (a base address, really), and what it points to is just an int. An int does not have enough space for 10 ints. You'll need to memcpy if you actually want to copy the data. Though, I'm not sure my solution is what the …

Member Avatar for Nathaniel10
0
74
Member Avatar for burcin erek

For std::string, I'd do it this way: [CODE] // case insensitive string compare function int compare_string(const std::string & s1, const std::string& s2) { std::string::const_iterator it1=s1.begin(); std::string::const_iterator it2=s2.begin(); size_t size1=s1.size(), size2=s2.size();// cache lengths //return -1 or 1 according to strings' lengths if (size1!=size2) return (size1<size2) ? -1 : 1; //stop when …

Member Avatar for burcin erek
0
147
Member Avatar for The physicist
Member Avatar for jonsca
0
192
Member Avatar for watery87

[CODE] void bookInput::displaybook() { cout<< "\tName:"<< title << " \t\t\tDate Published: " << date<< endl; } [/CODE] Why are you only inserting tabs? Maybe it only goes to a newline because it ran out of space on the right side. Just insert a newline if you want a new line. …

Member Avatar for Unimportant
0
190
Member Avatar for Nathaniel10
Member Avatar for bonucci

I know this is a C++ forum, but why don't you just do this in Ruby? Otherwise, make a thread that sleeps for 60 seconds and increments a counter by 1, when the counter is 120 (2 hours), reset it to 0 and execute the file read. Save the file …

Member Avatar for Unimportant
0
104
Member Avatar for athar89

Powers of 10? Assuming you want a decimal representation. You'll have to define 'digit', due to this ambiguity. 0xFF vs 255, 2 'digits' vs 3

Member Avatar for mrnutty
0
449
Member Avatar for Urv73

You can easily do it with a for loop, or any method of iteration. You could also track that information as soon as it is input, so that no iteration is necessary. (update average and total number) If you want more help than that, you'll have to post some of …

Member Avatar for Unimportant
0
75
Member Avatar for usshadowop

I'm not really sure what you think the code you have means, but to me it is a little bit silly. [CODE] void mystring::reserve(size_t n) { if(!n>buf_size) return; char *swap = new char[n]; // also it's better to use powers of 2 to prevent overhead memcpy(swap,ptr_buffer,buf_size); // copy the old …

Member Avatar for Unimportant
0
146
Member Avatar for kra9853

I really don't think what you want here is a switch, it would make sense in the ruby language, but C/C++ switch statements only accept constants: [CODE] switch( sum ) { case 100: case 99: // ... // yes you have to write them all case 96: letter='A'; break; case …

Member Avatar for Unimportant
0
239
Member Avatar for mybluehair

PlaySound("file.wav",NULL,SND_FILENAME|SND_ASYNC); Note the flag SND_ASYNC, which means that the file will play asynchronously during process execution (it won't block). So if you set this flag, it will play the file without 'pausing'

Member Avatar for Unimportant
0
173
Member Avatar for NoMoreKawasaki

instead of using parameters like this: int foo( int min, int max ); why not: [CODE] int range_rand( int a, int b ) { int high, low; (a<=b)?(low=a,high=b):(low=b,high=a); int ans=rand()%high; // I'm assuming you seeded rand already if( ans < low ) ans+=low; // this won't actually work if your …

Member Avatar for Unimportant
0
94
Member Avatar for lagvino_els

Rather than predefining your array a[], why not use the integer value of n as the final output? I don't like that you didn't post any code, but here's a hint: [CODE] for( i=0;i<n; ++i ) { a[i] = i+1; std::cout << a[i] << " "; } [/CODE]

Member Avatar for lagvino_els
0
95
Member Avatar for Violet_82

word.at(i) = test.at(j); [B]compare to:[/B] word.at( i ) = word.at( j ); // did you really want to write into what you're copying from? As for your warning: j = ( word.size() -1 ); j is an int, size() returns a size_t, which is an unsigned int In this case, …

Member Avatar for Violet_82
0
114
Member Avatar for sancharsharma

@sanchar MSVC (MicroSoft Visual Studio) is just an IDE/compiler, "Visual C++" -is- C++, though I wouldn't say with [B]complete[/B] certainty that it is 100% standards compliant, I think for your purposes it is effectively the same as "C++" MSVC comes with a resource creator (for drag and drop creation of …

Member Avatar for sancharsharma
0
105
Member Avatar for Dinnerfortwo

[CODE] while (num == 0) { cout << "Type in two values:\n"; cin >> num; // num isn't 0 if you enter anything but 0, no more while loop. [/CODE] You said "keep looping", obviously it won't loop if num isn't 0 If you want it to loop forever, try …

Member Avatar for Dinnerfortwo
0
131
Member Avatar for old_jefrey

[CODE] // use a template class template <typename T, typename T2> class DataCompare { public: // you can probably do this better, I just directly modified your example // It probably won't suit your needs, etc etc, might have typos bool operator()(const T& el1, const T& el2) const { return …

Member Avatar for old_jefrey
0
107
Member Avatar for shayankhan

[CODE] cmptr pc[1]=pc[0]; // this is a redefinition pc[1] = pc[0]; // this is what you actually wanted, assuming a was at least 2 cmptr *pc = new cmptr[100]; // this would be a = 100 pc[0].defaultinfo(); // both totally ok pc[99].defaultinfo(); // both totally ok // pc is a …

Member Avatar for shayankhan
0
240
Member Avatar for centerline00

char[25] can only hold '1' string of 25 character length, each character is 1 byte of data (char) for example, this isn't dynamic or anything, but if you did this: char[25][15] you could store 25 names, which are up to 15 characters long name[i] will be able to hold only …

Member Avatar for centerline00
0
115
Member Avatar for Bambam22

double array[r][1]; <--- r is 0, so this is the same as writing: [B]double array[0][1];[/B] You then go on to increment r: for(int r=0;r<20;r++) { and try to write out of array bounds: array[r][0] = tf; but the array only goes up to array[0], not array[1].

Member Avatar for Unimportant
0
139
Member Avatar for Milton Neal

std::stringstream std::fstream vs std::ostringstream std::ofstream std::ifstream etc... Edit: It seems I misunderstood your post, my apologies. Personally, I'd do it the C way, because it would be easier for me. That's just my taste though, you should do whatever is easiest for you.

Member Avatar for Narue
0
245
Member Avatar for awadojag

std::map<std::string,dvd> car_info; std::map will sort this array automatically based on the < operator for std::string std::map["volvo"] = dvd(constructor values); // or whatever temporary dvd you make

Member Avatar for awadojag
0
106
Member Avatar for gaurav_13191

Your problem is more related to the reason the limit system is a fundamental concept in calculus. How many square sides do you need to create a perfect circle? In this case, it's 1 per pixel. How is that any less taxing than using a single trig function for each …

Member Avatar for Adak
0
133
Member Avatar for xcr

last=MAX_UNSIGNED_INT? Sounds like you subtracted 1 from 0, as there are not that many words in a dictionary.

Member Avatar for Unimportant
0
93
Member Avatar for taquito86
Member Avatar for eduard77

Use the logical OR operator, which is "||" instead of "&&" "&&" is the AND operator (TRUE && FALSE && TRUE) evaluates to (FALSE) (TRUE || FALSE || TRUE) evaluates to (TRUE) [B]Edit: A poster above me already mentioned this, but you should probably read up on the logical operators …

Member Avatar for eduard77
0
97
Member Avatar for ccube921

[B]Edit: You should remember that error message specifically, because it is a misleading one for less experienced programmers.[/B] [CODE] struct attrib{ char x; int y; char cont; }; // <-- you didn't have a trailing semicolon attrib brd[8][8]; //ERROR WAS HERE <-- no it wasn't [/CODE]

Member Avatar for Unimportant
0
128
Member Avatar for chudapati09

To access a single member of a string, it's typically safer to call string::at(), as it checks that the value passed to at() is in range. substr() seems really round-about for getting just one character. std::string[] or std::string.at() are much better solutions for your problem In terms of processing an …

Member Avatar for chudapati09
0
178
Member Avatar for chintan_1671

Why not save each line as a string (whichever flavor you prefer), put those into any container/array, and then count them from there? You could easily do it with a multimap<std::string,int> for example, where int is incremented for each equivalent std::string, or set to 1 if the element did not …

Member Avatar for chintan_1671
0
154
Member Avatar for chintan_1671

[B]Edit: Clarification. 'When' you call getLeafCount(node->right), is the stack value of 'node' the same as when the function began at first? Short answer: No[/B] [CODE] int getLeafCount(struct node* node, int count) { int temp = 0; if(node!=NULL) { if((node -> data %2) != 0) { temp++; count = count + …

Member Avatar for chintan_1671
0
2K
Member Avatar for RobBobSmith

Operators are just functions, the reason you cannot pass () and [] as the same argument is that they are not necessarily the same function, they have different memory addresses and associated methodology. Rather, why not just overload your function? [CODE] void foo( int a ) { ; } void …

Member Avatar for RobBobSmith
0
138
Member Avatar for glenak

CreateThread() Main is just the primary thread. [B]Edit:[/B] There are many implementations of createthread, and variations (such as createthreadex), an example implementation of createthread which might make your life easier is boost::thread

Member Avatar for gerard4143
0
144
Member Avatar for Jsplinter

Poster above you was correct, please look at how this is different from what you did. [CODE] class myplayclass { public: int x; int y; vector<int> myVofInt2; myplayclass() : myVofInt2(10) {} // you can call its constructor like this ~myplayclass(){} myplayclass(int intX):x(intX), myVofInt2(10) {y=0;} }; int _tmain(int argc, _TCHAR* argv[]) …

Member Avatar for Jsplinter
0
175
Member Avatar for rashid85

I'm not sure I believe you, but if you aren't sure where to start, you could start by reading the documentation on std::fstream If you aren't allowed to use STL in your homework, read about these functions instead: fscanf() fgets() fgetc() fread() Good luck! If you want more help you'll …

Member Avatar for Fbody
-1
168
Member Avatar for vavazoom

if(file.is_open()) // is a good place to start Mind you, you may just not have enough RAM, especially with windows XP, to deal with a heap allocation of 1.5GB Programs such as 7zip, which unzip files of greater sizes in XP, do so with partial reading, intermediary files, or any …

Member Avatar for vavazoom
0
170
Member Avatar for hzp

cout << line[count] // <--- you are returning uninitialized data, as the variable count can be greater than the size of your input.

Member Avatar for hzp
0
125

The End.