456 Posted Topics
Re: Your coding work can be made *SO MUCH easier* ... if you JUST use a vector to hold the cites ... in the main program. (Then you can use the STL supplied vector iterators, etc..) See this running start: (Note all the code (sections) that has (have) /* not used … | |
Re: If you wanted to take in really long numbers ... you could use a large char buffer `char buffer[256];` to take in the chars using fgets Then easy to travese that buffer and extract pairs of numbers into an array of pairs `int pairs[100];` then process that array of integers | |
Re: while (rem_bal!=0); ... is a problem, since ... your running programm may never stop ... since, the double value rem_bal may never be exactly zero. When working with money, long long int ( or sufficently big integer value holding objects) ... is the way to go. You want your values … | |
Re: Do you already have a string class to work with? If NOT, you seem to be off on the wrong track ... ? A common student problem is to build ... bottom up ... a class String ... perhaps using a (dynamically allocated) C char string inside ... (a 0 … | |
| |
Re: The first step in solving a problem is a clear statement of what is required. You wrote this at the top: > ... been facing this problem for days ... have written a program where ... suppose to *read a specific number of lines* > within different intervals What does … | |
Re: Also ... interesting spelling :) #include <stdio.h> /* #incluede <string.h> */ /* that's how I feel sometimes :) */ #include <string.h> void getnames( char name[][50], int num ) ; void getnames2( char name[][50], int num ) ; void shownames( char name[][50], int num ) ; int main() { char name[5][50]; … | |
Re: > I am a robotic student and very new in python programming. Here, I have a project to classify the type of robot. For example, a customer would like to buy a robot arm for their company. So, this project will aid them to select robot of their choices. First … | |
Re: This quick example may get you started on the right track ... // sortVecPointers.cpp // #include <iostream> #include <vector> #include <algorithm> // for sort of vector elements ... using namespace std; ostream& operator << ( ostream& os, vector< int* > v ) { vector< int* >::const_iterator it; for( it = … | |
Re: > heyy all ,, i'm trying to get the middle word of sentence contains 3 words using find and substr ... Do you really have to use 'find' and 'substr' ? If not, as 'NathanOliver' has stated, using stringstream objects ... makes for a really nice C++ idiom here ... … | |
Re: @Anicia ... if you do really wish help, on your Python coding problem, please start a new thread and show what work (and code) that you have so far ... in the direction of solving the problem. | |
Re: It seems you still have NOT mastered a 'basic' here at Dani... i.e. submitting code in such a way as to preserve the indentation formatting ... Please learn how ... right away! The way I do it ... is like this: ->select and copy your source code (as you do … | |
Re: In C++ ... we commonly use 'cin' and 'getline' to get text ... and we commonly use 'cout' to print text to the console. These (iostreams) can be used in a user-defined function ... and often are ... in user defined functions with prototypes like: bool loadFromFile ( const string& … | |
Re: Did you mean ... a short hex char to int conversion ? // ascii_hex_char_2_int.cpp // // http://developers-heaven.net/forum/index.php/topic,46.0.html #include <iostream> #include <string> using namespace std; /* 48 060 30 00110000 0 49 061 31 00110001 1 50 062 32 00110010 2 51 063 33 00110011 3 52 064 34 00110100 4 … | |
Re: If your data file has validated data ... all like this: 500 - 1000 : 29 1000 - 1500 : 0 1500 - 2000 : 0 2000 - 2500 : 0 And, if all that you want is the int value at the end, (or possibly you want to fill … | |
Re: > what about the algorithm? Hey man ... promptText = "blablabla..." TopOfLoop: input = getInput( withPromptText ) if( ! valid( input ) ) goto TopOfLoop if( input == quit ) goto Stop getResultForInputAndShow( input ); goto TopOfLoop Stop: | |
Re: You could handle it some thing like this: void getPrimesInList( Clist* in, Clist* out ) { Node* cur = in->head; while( cur ) { if( isPrime(cur->value) ) push_backClist( out, cur ); cur = cur->next; } } | |
Re: Ok ... you got it working ... but ... What about ... if the user enters non-numeric char's when an int is expected? Try your program and see what happens? Try your program (as it is) as a (void) function call ... and loop in 'main' as long as the … | |
Re: It seems you were trying to show a MENU with 4 choices ... To print a big (graphic) letter, Choices are: Z or T or N or X Rather than a switch and case ... sometimes a TABLE is nicer :) // bigLetters.cpp // #include <iostream> #include <string> #include <cstdlib> … | |
Re: You may like to see this revision ... 1. that uses functions ... 2. that takes in ('crash safe') string input 3. that validates the input, in a loop, until valid 4. that demos using the same function in different ways, via a 'flag' variable ... also, 'default values' 5. … | |
Re: You can try an updated Dev ... has C++11 ... also 32 or 64 bit [Dev now has C++11](http://sourceforge.net/projects/orwelldevcpp/) | |
Re: Can't really check ... since some stuff missing ... too many problems to compile ... Turn all your compiler errors / warnings on ... See the changes / comments here / compiler warnings here they may help ? ... may get you stated on debugging your code ? #include <stdio.h> … | |
Re: Hey John, if you really wish to learn to code in C++ and / or C, you have one really great thing going for you, that all programmers need ... i.e. great persistance :) Once you have a good grasp on some basics ... things like how to keep the … | |
Re: When you begin computer programming ... don't leave your 'normal thinking skills' ... behind. How is the series 2,4,6,8, ... related to 1,2,3,4, .. . Answer: ? How could you design a program for this? Or ... if you start with 2 What can you keep adding to the previous … | |
Re: If you would like some ideas about coding / using big Integers, this link may give you a start ... [Big Numbers](http://developers-heaven.net/forum/index.php/topic,426.0.html) Also, you may like to know that Python comes with big integers ... (and big decimal precision also) ... so you may like to consider doing your program … | |
Re: Looks like a fun project ... can you code a working shell to get started? Announce what the program is about Ask for (validated) input Call a function, passing in input value, print output Ask if want to loop again? | |
Re: You may like to see this ref link to the sorts that already come in the C++ library [library sort](http://www.cplusplus.com/reference/algorithm/sort/) The example at the above link is for sorting a vector of integers. Below is an example of sorting a C++ STL list of C++ strings: // sort_list_of_string.cpp // #include … | |
Re: And when you hit the next letter ... i.e. when you reach B after printing all the A's ... print a blank line You may need to first switch to UPPER case every first letter in the names ... if some were entered with lower case first letters ... and … | |
Re: Just a variation on the theme... (for your enlightment and enjoyment) ... Note the simple looping exit condition ... The loop is exited when a cin error flag is raised by any invalid (here, any NON non-numeric) input ... #include <iostream> #include <iomanip> // re. formatting output ... #include <string> … | |
Re: If you look at this table: BASE Dig Max Decimal String rep (note string len = Dig col value) ======= == ========== ================================ base 2, 32, 4294967295, 11111111111111111111111111111111 base 3, 21, 4294967295, 102002022201221111210 base 4, 16, 4294967295, 3333333333333333 base 5, 14, 4294967295, 32244002423140 base 6, 13, 4294967295, 1550104015503 base 7, … | |
Re: Use a struct and the C++ STL queue to hold those data structs | |
Re: Have you done a web search on "C++ file handling" ? Then try out some code to create a simple text file of data lines Then read those lines back in (from the above file) and show them as you read each line These are the basics you will need … | |
Re: > ... code so that the user can choose a math operation and ... have that type of operation(either add sub mult or divide) run as much as a user wants ... Say, if the user wanted 5 addition questions only. And how do I keep track of the correct … | |
Re: [Check this link](http://www.daniweb.com/software-development/c/threads/474166/column-major-not-shown-right) | |
Re: > If the account balance falls below $800.00 at any time during the month, there is a $5.00 service charge for the month. This fee is only charged ONCE per month. You will need to keep a 3rd variable (perhaps a bool 'flag') to handle this. Passing all this info … | |
Re: Since you are coding in C++, why don't you use C++ string to hold your 'numbers' ... of ANY LENGTH? | |
Re: Did you read the link I gave you on your other post? (Please do not have multiple theads ... on the same subject.) [Click Here](http://www.cplusplus.com/reference/queue/queue/) | |
Re: A queue ... is just a first in ... first out (FIFO) data structure ... What are you trying to do with a queue ... C++ has one in the STL that you can test out, and use. [Click Here](http://www.cplusplus.com/reference/queue/queue/) | |
Re: And ... you could also ... simply do input like this: // monthDayYear.cpp // #include <iostream> #include <string> using namespace std; int main() { int mon; int day; int year; char dummy; const string month[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; … | |
Re: Do you know how to code a 'Hello World' C++ program? Do you know how to get integer user input (using cin) with a prompt for input? Do you know how to code to test if a is zero ? Do you know what 7 % 3 is ... in … | |
Re: //NOTE Oops ... unsigned value; cout << "Please enter a positive number: "; while (!(cin >> value) || value < 0) // Oops value is 'unsigned' so will never be < 0 // but ... may accept, i.e. no error flag raised, input of neg values ... but re-expressed as … | |
Re: Yes ... you are correct ... A string has: string s = "message"; A char has: char c = '!'; #include <string> // ... int main() { std::string input = "" // nice to show, but not needed since "" IS default constructor value while( input != "exit" ) { … | |
Re: This next link may also give you some ideas for input in a loop ... Note the steps. [6 Steps](http://developers-heaven.net/forum/index.php/topic,2019.0.html) | |
Re: See other post ... Please ensure all your example code is placed with indenting preserved. NO one wants to try to read C++ code that has NO proper indentation !!! Avoid indiscriminate use of global variables. Use descriptive variable names. Declare your variables just before used with sufficent scope only … | |
Re: You might like to look at split.h ... that emulates the Python split function in C A C string input, with the delimiters, returns a Clist of 'words' (dynamic C strings)... parsed out in accord with your choice of delimiters passed in. [split.h](http://developers-heaven.net/forum/index.php/topic,2584.0.html) | |
Re: Yes ... you can have a file to be included ... that is just a list of other file 'includes' ... that you need included. Make sure that you have 'unique guards' in the .h header files... Note: you can NOT define the same thing after it has been previously … | |
Re: > This (C++) lab will help you practice with C-strings and libraries. Function overloading (in C++) might come in handy, as well. > Two useful functions that are not provided in the standard library (*but are with standard C++ string*) are find a character in a string and find a … | |
Re: It looks like you have 6 companies ... And sales for 4 periods for each company ? This lends itself to a (data) struct using ONE array of struct (or better a C++ vector of struct) (NOT 2 arrays ... that is 'old-school'!) struct MyBus { string name; double[4] sales; … | |
Re: Since your are using C++, why not rather use C++ strings? // structStudent.cpp // // 2014-02-25 // #include <iostream> #include <string> using namespace std; struct Student { private: string firstName; string lastName; string telephone; public: void set_firstName( const string& fn ) { firstName = fn; } void set_lastName( const string& … |
The End.