- Strength to Increase Rep
- +9
- Strength to Decrease Rep
- -2
- Upvotes Received
- 122
- Posts with Upvotes
- 115
- Upvoting Members
- 72
- Downvotes Received
- 12
- Posts with Downvotes
- 9
- Downvoting Members
- 9
Enjoy helping beginners in C/C++ programming
- Interests
- Lots ... but mostly getting ready for soon return of Yeshua
- PC Specs
- 64 bit Win 7 OS
Re: Using several functions ... a function for each task ... could really help your program development ... and help elucidate the logic flow. // restaurant.cpp // #include <iostream> #include <string> // to keep code portable ... best not to use this // #include <windows.h> using namespace std; const string HEADER … | |
Re: Once you get started coding in Python ... and get some feel for its (often very) simple coding style and power ... you may then want to DO many of your programming jobs in Python first ... and many of those, then ... may never get recoded in C++ :) … | |
Re: If you were to google C++ file read / write you could find many code examples and articles to help ... ( also re. overloaded << and overloaded >> ) ... Here is a link with several file read / write examples ... You might like to take a look … | |
Re: I haven't checked in for a long time ... We are, for sure, living in the time, long foretold, of *Great Deception* ... see Matthew 24. The first thing I heard Trump say, back in 2016, was: *I was greedy for myself, but now I'm going to be greedy for … | |
Re: You may get a few coding ideas from the related examples here: http://developers-heaven.net/forum/index.php/topic,2022.msg2680.html#msg2680 | |
Re: or? .... could use latest Python 3 with: import sqlite3 | |
Re: Hey @ Zain_4 ... Do you realize that it is *not* proper etiquette to *hijack* a thread? If you wish to ask a new question, please start a new thread ... and if you need programming help with an homework question ... you will NEED TO FIRSTLY show us the … | |
Re: Firstly, you may like to note that you mentioned using a vector of characters, but your code uses C++ strings, which is probably what you really meant to say? Also, you need to lean to break up your program into 'jobs' ... and each job can be called by coding … | |
Re: Also ... in C++ you usually do NOT want redundant parameters in a class! For example, in a circle, if you know one of: radius, diameter, circumference, area you can calculate all the other ... And note that PI (pi) is a constant value defined as the ratio of the … | |
Re: Did you realize that you are taking in your 3 data elements twice? And that the 2nd 'take in' set of data ... over-write the first? Also ... do you realize that in math: For any value a, ( a - 0.18*a ) = a * (1 - 0.18) = … | |
Re: Sometimes a table-lookup method is a nice way to handle problems like this. You might like to see the examples here: http://developers-heaven.net/forum/index.php/topic,134.msg709.html#msg709 | |
Re: You may like to try someting like this to get valid input and to prevent program crashing on accidental input of an invalid type. #include <stdio.h> #define ROWS 5 #define COLS 10 #define COST_PER_SEAT 150 /* Simple input of an integer... i.e. NO range checking done */ int takeInInt( const … | |
Re: You seem to have two distinct parts to your project: 1) Code and test a class String 2) Use that class (and perhaps some of its methods) to process lines of words. It may be helpful to start with part 2) and there, using the C++ string until 2) is … | |
Re: Where in your code is the problem ... what lines ? What are the error messages? If you have a static method in class A you can call like this: A.yourAstaticMethod(anyArgsGohere...); Otherwise you need to firstly create an object of class A A a; // call default ctor... a.yourAmethod(anyArgsGoHere...); | |
Re: It is now past 17:30 EST ... and you will need to ask for an extension if you still need help with your school project ... In the future ... if you wish help at this very willing to help, help site, please firstly supply us with the code you … | |
Re: @ Dean_5, are you a Java programmer? You said: > ... C++ doesn't allow string comparison via "==" ... Please take a look at: http://www.cplusplus.com/reference/string/string/operators/ | |
Re: One quick way to handle this, that easily extends to 'integers' of any length, is to input your numbers as strings ... and then to code a function to increment each 'digit' in this string as proscribed ... with a carry term to the 'next left' digit for the case … | |
This thread will be an attempt to develope a SIMPLE (and good enough) class for beginning Java students, to ease their coding for valid and crash proof, user (Console type) input, (and also handle Console output.) We assume here that beginning students need not worry much, about obtaining the fastest … | |
Re: Try these three files: 1st: import java.util.Scanner; public class Console { private static Scanner sc = new Scanner(System.in); public static void displayLine() { System.out.println(); } public static void displayLine(String s) { System.out.println(s); } public static String getString(String prompt) { System.out.print(prompt); String s = sc.nextLine(); return s; } public static int … | |
Re: Is there a clue in the Dani user name that has a `C++` in it, as in: `Linzi c++` Maybe it's some kind of generic code ? So ... to answer the request about coding an input request: `int radius = takeInInt( "Enter your desired radius: " ); // 'takeInInt' … | |
Re: As suggested above, you seem to be a bit confuzzed? Working with C++ binary files can be a little tricky, especially at the beginning. I'm not sure what you were supposed to do here, but here is a little demo class to show how one might append int values to … | |
Re: You could use some class methods to aid console string input as per here; https://www.daniweb.com/programming/software-development/threads/506093/java-output Also a class for Customer with methods and a class for Item with methods maybe each could have takeInInfo methods also ? Then all you need is a loop with in a loop as per … | |
Re: It is good for you to learn, as early as possible, some simple 'student type' ways to get numeric imput ... from a keyboard user, so that the running program will nor crash if invalid data was entered. The following little demo may help to get you started in that … | |
Re: Here is a little more general way one might handle a problem like this ... (the code also demo's using templates in C++.) // print_a_col.cpp // #include <iostream> using std::ostream; // set here what you need ... const size_t NUM_COLS = 4; // NOTE: below we pass in ALL parameters … | |
Re: In C++, best NOT to use C type strings. Use C++ string instead. The C++ string will size itself to be the right size to hold your string and can be as big as available memory for a C++ string See: http://www.cplusplus.com/reference/string/string/ and: http://www.cplusplus.com/reference/string/string/max_size/ | |
Re: I might start off with a very simple bottom up re-design with planes coming into a queue and departing from the same queue in fifo order ... with maybe something like ... ? struct Plane { int id; string from; string arrived; string to; string departed; } ; struct Gates … | |
Re: I would start fresh and use a C++ typedef vector< vector < double > > Matrix; then code something, beginning like the following, to exploit the power built into C++ ... void takeIn( Matrix& mat ); Matrix& operator += ( Matrix& a, const Matrix& b ); Matrix operator + ( … | |
Re: Maybe you want this? while(getline(infile,substance[index],',')) { // getline(infile,substance[index],','); // done above // infile >> molWeight[index]; } It is hard to tell what you want without some sample data file. Perhaps the following example of reading a csv data file might help? // fileReadWriteStudent_csv.cpp // #include <iostream> #include <iomanip> // re. … | |
Re: int q = 10; void fun(int *p) { *p = 15; // after this point, the 'int' at the address passed in holds 15 p = &q; // NOW ... p holds a different address, the address of global q printf("%d ",*p); } | |
Re: Or ... (sorry to be a little late getting back) ... you might like to see a type of 'table look up' solution approach .. that can reduce code bulk and streamline logic flow ... # examplePairsInList.py # def takeInFlt( msg ): ok = False flt = 0.0 while not … |