How to make makefiles and vectors

Hey, does anyone know what a code for a makefile would look like? I want to compile main.cpp cash.cpp cash.h checks.cpp and checks.h.
Also what would a vector that hold a set of numbers between 1-9 and when the user inputs a number between 1-9 it takes it out of the vector so that they can't use it again look like.
Thank in advance
Hey, does anyone know what a code for a makefile would look like? I want to compile main.cpp cash.cpp cash.h checks.cpp and checks.h.

I would imagine a Google search for "makefile tutorial" would give you the basic understanding you need.

Also what would a vector that hold a set of numbers between 1-9 and when the user inputs a number between 1-9 it takes it out of the vector so that they can't use it again look like.

Can you be a bit more specific about which part of this problem you're having trouble with? Is it reading the user input? Is it manipulating the vector to remove the number that the user's chosen? Or is it some other aspect of the problem?
https://www.cs.swarthmore.edu/~newhall/unixhelp/howto_makefiles.html
(Since Google returns a lot of not-so-parsable reading.)

[OP is newb asking basic questions.]
Read the docs.
http://www.cplusplus.com/reference/vector/vector/erase/
(Comes complete with a couple of examples.)

Good luck!
OP asks about MakeFiles where a batch script would do just fine and then proceeds to ask a basic question about pre-populated vectors...


Don't worry OP, I've got ADHD as well. Just try to minimize the number of things that you're focusing on and you'll do just fine.
Thanx! @Mikey Its reading the user input and then when its inputted taking it out of the vector so that the input can't be used again
example if the user enters 9 it would take the number 9 out of the vector so that when the user enters it again it would prompt and error
Yes, I understood your description of what the software is supposed to do.

I was asking which specific aspect of it you don't know how to do.
The kind of behavior you are asking for properly belongs to a set:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <set>
using namespace std;

int main()
{
  set <int> valids{ 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  
  while (!valids.empty())
  {
    int n;
    cout << "Enter a number you haven't entered yet in 1..9: ";
    cin >> n;
    
    if (!valids.count( n ))
    {
      cout << "Fooey! You lose!\n";
      return 0;
    }
    
    valids.erase( n );
  }
  
  cout << "Good job!\n";
}

However, if you really want a vector, the code is similar (if only a little clunkier):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main()
{
  vector <int> valids{ 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  
  while (!valids.empty())
  {
    int n;
    cout << "Enter a number you haven't entered yet in 1..9: ";
    cin >> n;
    
    auto iter = find( valids.begin(), valids.end(), n );
    if (iter == valids.end())
    {
      cout << "Fooey! You lose!\n";
      return 0;
    }
    
    valids.erase( iter );
  }
  
  cout << "Good job!\n";
}

Hope this helps.
There are several different "build systems" that let you decribe your "project" in their own format and then generate a proper Makefile for you. GNU build system, cmake, Qt's qmake, various IDE's, ...
cmake is... not easy to learn, but I have to say, I've been very impressed with it. If I'm ever in the position of having to write the build files for a cross-platform project, I'd be very tempted to use it.

I've always found makefiles horrible!
Topic archived. No new replies allowed.