2,712 Posted Topics

Member Avatar for jim_underpants
Member Avatar for tomtetlaw

You could use a gui library, possibly QT or wxWidgets or create your own

Member Avatar for mrnutty
0
55
Member Avatar for Raisefamous

>>Even on an embedded system, that is hardly a memory hog. How about calculating 100! or 1000!, putting aside the limitation of data-type of course. Anyways, usually tail recursion can be removed by compiler's optimization. OP have you learned about functions? Try to modularize your code by using functions. [code] …

Member Avatar for WaltP
0
259
Member Avatar for LevyDee

What is the problem? If you can't use std::vector, then why not use std::list? Why are you using memcpy? Just use operator= for more clarity.

Member Avatar for mrnutty
0
110
Member Avatar for EvaL2ne

Dont read it line by line. Instead, read it word by word. The check if each word is a valid real number. Example: [code] int main(){ ifstream fileIn("input.txt"); string word; unsigned int count = 0; while( fileIn >> word ) { if( isRealNumber( word ) ){ //you need to implement …

Member Avatar for WaltP
0
318
Member Avatar for Labdabeta

I kind of like the idea of unary plus being an absolute value sign. Right now, the unary plus is nothing more than extra information to the user. Maybe to hint to the user that it should always be a plus or something. It has no effect.

Member Avatar for mrnutty
0
301
Member Avatar for jeevsmyd

Use std::strings [code] int main(){ string label,topcode,toperand; ifstream fileIn("input.txt"); while( fileIn >> label >> topcode >> toperand){ cout << "Label = " << label << endl; cout << "TopCode = " << topcode << endl; cout << "Toperand = " << toperand << endl; } } [/code]

Member Avatar for jeevsmyd
0
810
Member Avatar for DACP

You should use the getline function, which reads the first line from input. Then you can use the first character to determine the proper equation to use. Here is an example. [code] string line; //while there is a line to get while( getline( fileIn, line) ){ switch( line[0] ){ //check …

Member Avatar for mrnutty
-1
2K
Member Avatar for Hiiero

Your logic seems false. Line 3: You create a node t Line 16: You search for the int value then then updated t's frequency? But t is a new node not necessarily inside the binary tree! What you want is a helper function that returns the Node who has the …

Member Avatar for mrnutty
0
136
Member Avatar for challanger

Line 14-18 set all pointers to null. Line 21 check if driver is null comment out line 23 and see if it runs fine.

Member Avatar for challanger
0
1K
Member Avatar for sodalee702
Member Avatar for ztdep

Seriously how hard is it to perform a [URL="http://www.google.com/webhp?sourceid=chrome-instant&ix=e1&ie=UTF-8&ion=1&nord=1#hl=en&nord=1&site=webhp&sa=X&ei=HeboTruBAsjd0QHeyeTlCQ&ved=0CBgQvwUoAQ&q=C%2B%2B+matrix+library&spell=1&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=a6957c99ad62c3c8&ion=1&biw=1276&bih=683"]google search[/URL]? Just pick one of the top ones. Sorry for sounding rude, but sometimes independency is what should be utilized to increase productivity

Member Avatar for ztdep
0
177
Member Avatar for v3ga

If your on linux you can use the '<' operator. As in [icode] ./app < fileName [/icode] it gets the input from the file instead of direct terminal.

Member Avatar for v3ga
0
215
Member Avatar for stamatt45
Member Avatar for babyhuyx

Your code is hard to read but your problem is in line 15, your using the array and it hasn't event been initialized it. Usually when you use an array, you you use hardcoded index when you want to access all values. What you are looking for is something like …

Member Avatar for cutenaj12
0
2K
Member Avatar for Srinivas0
Member Avatar for mrnutty
0
258
Member Avatar for anamoblu56

You adding it twice here : [code] for (int day = 0; day < 7; day += 1) for (int temps = 0; temps < 2; temps += 1) tot += tempav[day][0]; { cout << " Total Col 1 " << tot << endl; } [/code] just do this: [code] …

Member Avatar for anamoblu56
0
103
Member Avatar for ahoysailor

Another option is to supply your comparison method to std::sort: [code] int getDigitFromLine(const std::string& line){ const string digits = "0123456789"; size_t beg = line.find_first_of(digits); size_t end = line.find_first_of(digits); string digitString = line.substr(beg, end-beg + 1); return atoi( digitString.c_str() ); } bool mycomp(const std::string& lhs, const std::string& rhs){ int lhsNumber = …

Member Avatar for mrnutty
0
177
Member Avatar for Arkinder

[icode]std::cin.getline(const_cast<char *>(name.data()), MAX_NAME_SIZE);[/icode] is undefined behavior because you are not allowed to modified the pointer-to-const-char returned by data. You could easily just use the c-style approach and convert that into a string. Or you can do something like so. [code] string str(' ',MAX_SIZE); cin.getline( &(str[0]) , str.size() ); [/code]

Member Avatar for Arkinder
0
6K
Member Avatar for MadeleinePV

How about you make a helper function to reduce work. [code] class Logger{ private: ostream *stream; public: Logger(ostream& strm) { stream = &strm; } void log(const std::string& msg){ _log(msg); } private: void _log(const std::string& msg){ (*stream) << msg << endl; } }; [/code] And so now you just call [icode] …

Member Avatar for mrnutty
0
973
Member Avatar for easterbunny

Couple of options. 1) Read it into a string and work from there 2) Split the digits and work from there - to split the digits you can use the divide and modulus operator And I am guessing your avoiding arrays because either your assignment says you cannot use them …

Member Avatar for easterbunny
0
2K
Member Avatar for dolfan55aj

When you delete a node from a graph, to update your adjacency matrix you can either remove the column and row associated for that row. For example [code] Let node = 1 2 3 And its initial adjacency matrix be: 1 2 3 1 0 0 0 2 0 0 …

Member Avatar for mrnutty
0
966
Member Avatar for mrnutty

I'm graduating this december and I got a job offer!!! Will be working for FactSet. I can't believe it. This is so crazy. Thanks everyone for helping me when in need. I'm just so happy :) regards firstPerson

Member Avatar for Netcode
1
175
Member Avatar for Vasthor

>>[B]Rewrite the Student_info structure to calculate the grades immediately and store only the final grade.[/B] Seems like you want to do this in the constructor. Here is an example. [code] #include <iostream> struct Sum{ int total; Sum() : total(0){} Sum(int max): total( _calculate(max) ) { /*sum calculated already */} int …

Member Avatar for Schol-R-LEA
0
249
Member Avatar for desolatebeast

Test this : [code] #include <iostream> using namespace std; int main(int argc, char * argv[]){ for(int i = 0; i < argc; ++i){ cout << "Argument[" << i < "] = " << argv[i] << endl;; } } [/code] You can call it like [icode] ./ExecutableName arg1 arg2 arg3 [/icode]

Member Avatar for thines01
0
164
Member Avatar for fmasroor

> `using namespace std;` your probably confused about what the above does. Look up 'C++ namespace'. In short, it makes public data that is in std namespace in your current scope. So instead of doing `std::cout << "hello"` you can simply do `cout << "hello";`. Notice I didn't have to …

Member Avatar for Schol-R-LEA
0
119
Member Avatar for MrAppleseed

It looks like depending on what the string contains you want to do certain action. You should look into the command pattern. Anyways here is one way. [code] #include <iostream> #include <string> #include <vector> using namespace std; struct Command{ virtual void execute(const std::string& commandString) = 0; ~Command() {} }; struct …

Member Avatar for MrAppleseed
0
305
Member Avatar for jonspeidel

>>[B] if((s3=="Y" || "y"))[/B]] You want[icode] if(s3 == "Y" || s3 == "y")[/icode] or [icode] if(s3.find("yY") != string::npos) [/icode] or [icode] if(tolower(s3[0]) == 'y') [/icode]

Member Avatar for WaltP
0
253
Member Avatar for lmytilin

Yup tolower return the 'lower' version of the argument passed if valid. IT does not change the argument to its lower-cased version

Member Avatar for mrnutty
0
107
Member Avatar for jeevsmyd

[QUOTE=jeevsmyd;1703420]Suppose I have a simple program to find the largest of two numbers of different datatypes and return the largest.I'm implementing it as a template to support generic datatypes [code] template<class T,class U> T max(T t,U u) return (t>u?t:u); int main() { int x=70; float y=100.5; max(x,y); return 0 } …

Member Avatar for mike_2000_17
0
225
Member Avatar for eshalmj

Whenever you have a "big" assignment like that, its really good to break it down. Here is the first thing your should do : <quote> Create an [B]inheritance [/B]hierarchy containing [B]base class Account[/B] and [B]derived classes SavingsAccount and CheckingAccount[/B] [B]that inherit from class Account[/B]</quote? Draw this out on paper. Let …

Member Avatar for divyakiran
0
888
Member Avatar for XodoX

>>[icode] omp_get_max_threads ( ) [/icode] Spacing issue I think. Try [icode] omp_get_max_threads( )[/icode]

Member Avatar for mrnutty
0
1K
Member Avatar for user543820
Member Avatar for MrEARTHSHAcKER

Um... you have to check it for all character [code] //check if str contains only digits bool isDigits(const std::string& str){ bool isValid = true; for(int i = 0; i < str.size(); ++i){ if(!isdigit(str[i])){ isValid = false; break; } } return isValid; } [/code] Note, this code might be ambiguous in …

Member Avatar for MrEARTHSHAcKER
0
209
Member Avatar for rhn94

Just some few comments/questions first. 1) you might want to think twice on that hungarian notation. 2) Does the order of the elements in the string matter? For example does the last element has to be the last ? So does the element position matters relative to its neighbors?

Member Avatar for rhn94
0
194
Member Avatar for arc45

Your user interaction logic would look something like this : [code] string userInput; const std::string DONE = "done"; do{ cout << "Enter a command to call[ add, print, delete, done ] "; cin >> userInput; if( userInput == "add"){ /* ask user what to add then add it to the …

Member Avatar for shinnoon
0
2K
Member Avatar for subith86

>>Even though both variables have the value 30 in it, the if-condition gets satisfied and exception is thrown The int gets promoted and you are now doing a floating comparison. When doing floating comparison, as of right now you can do a simple range comparison : [code] //checks if lhs …

Member Avatar for Tumlee
0
203
Member Avatar for icebirdy

So you need to perform a check. Something like so : [code] while(fileIn){ const char peekChar = fileIn.peek(); switch(peekChar){ 'A': createObjectA(fileIn); break; 'B': createObjectB(fileIn); break; default: /* error, object not supported */ break; } } [/code] [icode]cin.peek()[/icode] just peeks at the next character but doesn't 'read' it. So you can …

Member Avatar for mrnutty
0
150
Member Avatar for UNDER-18 FG

Have you learned about for-loops? If so then using for loops is the correct way to solve this problem.

Member Avatar for mrnutty
0
333
Member Avatar for Chuckleluck

Modern games are usually made with OpenGL, DIrectX, XNA or something else than win32. My advice to you is to not worry about win32 and pick up either opengl or directx

Member Avatar for mrnutty
0
502
Member Avatar for phorce

Thats one approach. 1) You calculate the frequency of each letter in the ciphered text. 2) You have a frequency map for the english text 3) Get the highest frequency character in the ciphered text, and replace it with the highest frequency character in the map form step 2. 4) …

Member Avatar for mrnutty
0
99
Member Avatar for sita12345

Are you trying to delete a vector of pointers? [code] std::vector<x*>::iterator begin = x.begin(); while(!x.empty()){ x* tmp = x.back(); x.pop_back(); delete tmp; } x.clear(); [/code]

Member Avatar for sita12345
0
367
Member Avatar for Johnnyj01

Or maybe its conceptually better to have one boolean : [code] bool done = false; bool validMove = true; bool shouldContinue = true; do{ //... shouldContinue = done && validMove; //should continue only if all test are passed }while(shouldContinue); [/code]

Member Avatar for Johnnyj01
0
108
Member Avatar for spicyrelish

In line 16 and 19, you are using State2 and State3, respectively, without defining State2 and State3 previously. At that line, the compiler doesn't know that State2 and State3 is. So it spits out an error.

Member Avatar for mrnutty
0
138
Member Avatar for skylinedrifter

You got the first step correct -- to create a enum list. Now your next task is to create a function that given a Enum Planet, it returns the string version of its name. here is a start. [code] #include <iostream> #include <string> using namespace std; enum Planet {MERCURY, VENUS, …

Member Avatar for mrnutty
0
863
Member Avatar for mrnutty

This code below add two positive numbers in any base from binary to base 36 with any length allowed by memory. The snippet comes with examples. There might be some bugs, because I haven't tested extensively, so forgive me if you find bugs. Hope people find it useful somehow. Thanks …

Member Avatar for Tumlee
0
690
Member Avatar for james6754
Member Avatar for Moschops
0
124
Member Avatar for lele07060

>>[B]((i-2)/i);[/B] your doing integer division. You want [icode] sum += (float)(i - 2) / i; [/icode]

Member Avatar for stultuske
0
129
Member Avatar for BoBok2002

[B]>> Should I include the whole path name or just the image name? [/B] If the file is in the same directory as your source file, then you can just use the filename, else you can either use relative path or full path. However it needs to be a valid …

Member Avatar for BoBok2002
0
5K
Member Avatar for maynardjk13

You need to put line 69-70 in line 72. [code] bool isPrime(int num){ for(int i = 2; i < num; ++i){ if(num % i == 0) return false; } return true; } [/code]

Member Avatar for mrnutty
0
252

The End.