• Member Avatar for David W
    David W

    Replied To a Post in Deleting duplicate strings from an array of strings

    If you sort the array of strings ... you can then traverse the sorted array and skip over all duplicates
  • Member Avatar for David W
    David W

    Began Watching std::string::size_type and typedef

    Hi i'm following a book but i don't understand `std::string::size_type` and some other data types specially `typedef` i see programmers use them too much. typedef int grades[5]; grades studenA[5], studentB[5]; …
  • Member Avatar for David W
    David W

    Replied To a Post in std::string::size_type and typedef

    re. the other part of your question ... the use of typedef can either be helpful to your code flow or hinder (hide from) your understanding what the code is …
  • Member Avatar for David W
    David W

    Replied To a Post in inventory system (get free slot)

    Really ... one does need more info and the particulars of your inventory data management problem ?
  • Member Avatar for David W
    David W

    Began Watching inventory system (get free slot)

    Anyone can help me? I have inventory system which works with item-bags. There are 4 different item-bags. 1 bag have 4 other 8, 12, 16. Now for the NPC shop …
  • Member Avatar for David W
    David W

    Replied To a Post in inventory system (get free slot)

    One way (off the top) could be ... struct Bag4 { bool filled; string items[4]; Bag4() : filled(false) {} } ; // etc ...
  • Member Avatar for David W
    David W

    Replied To a Post in Write a program that reads in a set of positive integers, representing test

    @R_R_A please note: the above post was not meant to in anyway discourage you from studying the very useful code example by @tinstaafl You will do well to study his …
  • Member Avatar for David W
    David W

    Replied To a Post in Sum of ages

    Actually ... I like this for 'simple student type validation' of keyboard user input of integers ... int takeInValidInt( const char prompt[] ) { for( ; ; ) /* an …
  • Member Avatar for David W
    David W

    Began Watching Sum of ages

    Read the age and weight of 5 people. Calculate the sum of the ages of people over 70 Kg #include <stdio.h> int i, age, weight, sum; main() { for( i=0; …
  • Member Avatar for David W
    David W

    Replied To a Post in Sum of ages

    You can read the returned value when using scanf or fscanf, to see if an appropriate value was 'scanned in': http://developers-heaven.net/forum/index.php/topic,2022.0.html int getValidInt( const char prompt[] ) { for( ; …
  • Member Avatar for David W
    David W

    Replied To a Post in Write a program that reads in a set of positive integers, representing test

    The OP wanted to be able to print out the original scores that were in the file ... so these would need to be printed out as they were read …
  • Member Avatar for David W
    David W

    Replied To a Post in Write a function, CountElement, that receives two arguments...

    Take a look at this revision that uses a (data) struct to simplify and help organize the flow of the data processing: /* Write a function, CountElement, that receives two …
  • Member Avatar for David W
    David W

    Began Watching Write a program that reads in a set of positive integers, representing test

    Okay, I was given this problem, its another of those file I/O streams and I was wondering how I can change this code to be more "efficient" and change a …
  • Member Avatar for David W
    David W

    Replied To a Post in Write a program that reads in a set of positive integers, representing test

    This example may be closer to what would be expected of just a 'beginning student: 1 -> NO STL used 2 -> Simple bubble sort used 3 -> Only tricky …
  • Member Avatar for David W
    David W

    Replied To a Post in Write a function, CountElement, that receives two arguments...

    In any case you will want to see this: http://www.cplusplus.com/reference/cctype/ remember to: `#include <cctype>`
  • Member Avatar for David W
    David W

    Began Watching Write a function, CountElement, that receives two arguments...

    Okay, I have another problem that I can't figure out and it has to do with the I/O file stuff. This is the problem: Write a function, CountElement, that receives …
  • Member Avatar for David W
    David W

    Replied To a Post in Write a function, CountElement, that receives two arguments...

    Not sure what you are trying to do ? > function counts the number of digits, small letters, capital letters and symbols in the char array, and returns the counts …
  • Member Avatar for David W
    David W

    Replied To a Post in No matching constructor for initialization

    I really can not tell without seeing your exact code and having the exact same testing setup. But ... C++ code that is well written ... to accord to standard …
  • Member Avatar for David W
    David W

    Replied To a Post in Logical error

    But ... better to use C++ string and getline for input of names. Also ... you will want to validate / handle bad (numeric) input (especially - so your program …
  • Member Avatar for David W
    David W

    Began Watching Logical error

    Hello to all! I am a begginer to C++ and writing a class . Actually my program runs perfectly but there is logical error. My compiler is devC++. the output …
  • Member Avatar for David W
    David W

    Replied To a Post in Logical error

    Your code above will NOT compile error free. See the '1st round' of corrections suggested ... (see changes and added comments) //#include<iostream.h> #include <iostream> // need to add using namespace …
  • Member Avatar for David W
    David W

    Began Watching Receive a number from the keyboard and tell you if it is divisible by...

    Receive a number from the keyboard and tell you if it is divisible by 10, 5, 2 or if it is not divisible by any of these. Why this dont …
  • Member Avatar for David W
    David W

    Replied To a Post in Receive a number from the keyboard and tell you if it is divisible by...

    Also note: if number is divisible by 10 ... it is ALSO divisable by 5 and 2 ... and it will end with (at least) one 0 if number is …
  • Member Avatar for David W
    David W

    Began Watching read record from file

    using namespace std; struct karmand{ char nam[10]; char shomare[10]; char sx[10]; char mm[10]; char rgh[10]; }list[s]; void search(); void prin(int i); void input_file(); void enter(); int a; void menu_select(){ char …
  • Member Avatar for David W
    David W

    Replied To a Post in read record from file

    What is this: using namespace std; struct karmand{ char nam[10]; char shomare[10]; char sx[10]; char mm[10]; char rgh[10]; }list[s]; /* s = ??? */ Don't you mean to code: struct …
  • Member Avatar for David W
    David W

    Replied To a Post in No matching constructor for initialization

    You need to add ... `#include <cstdlib> // re. exit` but do not use exit ... It's not really needed ... Just return some none 0 error (flag) value, if …
  • Member Avatar for David W
    David W

    Replied To a Post in No matching constructor for initialization

    Ok ... here is a 'debugging' problem / solution process to try :) Take my code ... compile check Then replace blocks/functions with 'comparable code' from your program ... compile …
  • Member Avatar for David W
    David W

    Replied To a Post in area and volume occupied by a cylinder

    Oops ... see/use the following instead (to take in a float) (I had modified the code from a student example I gave years ago ... an example for integer 'take …
  • Member Avatar for David W
    David W

    Replied To a Post in No matching constructor for initialization

    > you still did not offer a solution to my problem of initializing an object with no parameters (using the default values in the constructor). Please note the changes to …
  • Member Avatar for David W
    David W

    Replied To a Post in No matching constructor for initialization

    Did you not read, research ... and then understand the added comments? > I understand everything except for your usage of size_t, and the clearing of the cin error flags. …
  • Member Avatar for David W
    David W

    Replied To a Post in inline functions require that they be defined in each file

    @L7Sqr I appreciate your concern ... the example I provided was an example of a 'real' use ... in a typical student type coding problem / solution. The example only …
  • Member Avatar for David W
    David W

    Began Watching Variable LIST length and output formatting

    I'm working with a LIST that am getting from a soup which after the clean up gives me: lists of variable length ['7.0', '7.5', '6.8', '6.9'] or ['7.0', '7.5'] so …
  • Member Avatar for David W
    David W

    Replied To a Post in Variable LIST length and output formatting

    It appears * that you have an even number count in your lists of grades ... and * you want the output to be formatted as a list of list …
  • Member Avatar for David W
    David W

    Began Watching area and volume occupied by a cylinder

    Calculate the total area and volume occupied by a cylinder. Correct or not? #include <stdio.h> #include <math.h> int main() { float At, V, r, h; printf("\n ===========Calculate the total area …
  • Member Avatar for David W
    David W

    Replied To a Post in area and volume occupied by a cylinder

    Some next steps: 1. validate and 'crash proof' input 2. loop for more input until no more input desired 3. break up program into jobs using functions This little demo …
  • Member Avatar for David W
    David W

    Began Watching Pointer

    I am confused about pointer , it takes value of a vairable or only takes adress of vairable ??
  • Member Avatar for David W
    David W

    Replied To a Post in Pointer

    You could say that a pointer variable holds addresses ... adresses for any kind of 'object' ... including the address of an other pointer variable ... and in that case, …
  • Member Avatar for David W
    David W

    Began Watching No matching constructor for initialization

    Hello programmers! I have been working on a hardware store application, where there is a `HardwareRecord`class that stores information about each object in a store (ex: nuts, bolts, screws, and …
  • Member Avatar for David W
    David W

    Replied To a Post in No matching constructor for initialization

    I think you can really clean up your code still and simplify it lots ... Take a look at this and see the added comments ... file: HardwareRecord.h // file: …
  • Member Avatar for David W
    David W

    Began Watching inline functions require that they be defined in each file

    **The special rules for inline functions require that they be defined in each file in which they are used.The easiest way to make sure that inline definitions are available to …
  • Member Avatar for David W
    David W

    Replied To a Post in inline functions require that they be defined in each file

    You may also like to see this: http://www.parashift.com/c++-faq/inline-functions.html Here is an example that you can see where 'inline' might be appropriately placed and used ... file: nvector.h // file: nvector.h …
  • Member Avatar for David W
    David W

    Replied To a Post in [vectors] 3D vectors?!

    Or ... a very simple way to start could be like this ... (that lets readily you use all the STL vector member functions) // schools.cpp // #include <iostream> #include …
  • Member Avatar for David W
    David W

    Began Watching [vectors] 3D vectors?!

    Hi, I am trying to design a vector within a vector within a vector. For example, a school has 3 floors, each floor has 5 classrooms, each classroom has 20 …
  • Member Avatar for David W
    David W

    Replied To a Post in Write a program that merges the numbers in two files and writes...

    After you have the above working ... see added code and better comments here ... (but note the simpler and more symetric code demo'd above ... the 2nd example) #include …
  • Member Avatar for David W
    David W

    Replied To a Post in Write a program that merges the numbers in two files and writes...

    try this fix: // mergeFiles( ifstream& fin1, ifstream& fin2, ofstream& fout ); // <== you had this WRONG line // mergeFiles( inputFile, inputFile2, outputFile );
  • Member Avatar for David W
    David W

    Replied To a Post in Write a program that merges the numbers in two files and writes...

    I just remembered a previous example I did some time ago, with a simpler code ... Take a look and you may see why I prefer this simpler (and more …
  • Member Avatar for David W
    David W

    Replied To a Post in Write a program that merges the numbers in two files and writes...

    Yes ... using the STL set (or multiset) is sure a whole lot easier to code and use ... if your files *will both fit* into (available) memory :)
  • Member Avatar for David W
    David W

    Began Watching i am need a simple super mario game by using 2d c++

    iam need to complete this game with ( jumping function - hero - enemy - the fire of enemy ) please ... iam really need your help ‪#‎include‬<iostream> #include <conio.h> …
  • Member Avatar for David W
    David W

    Replied To a Post in i am need a simple super mario game by using 2d c++

    Does your program compile? Are there errors? Can you isolate (provide a small sample of code to illustrate where the error seems to be?) (And when you copy/paste your code, …
  • Member Avatar for David W
    David W

    Began Watching Greatest Common Factor of Many Numbers

    Hello guys. I need an idea. How can I calculate GCF of many numbers? I thought I could calculate two by two numbers, but it not seems to be a …

The End.