Making a makefile for my assignment

I am new to using makefiles and I am currently in a datastructures class where they must be used. I am using linprog on unix. I need help making a makefile because my T.A.'s have not been helping me with it. Here is the decription of my assignment
Educational Objectives: Refresh C/C++ programming skills. Use C++ I/O streams, string class, and STL containers and algorithms. Use makefile to organize and compile programs. Use debugger to identify and address programming problems.

Statement of Work: Implement a program that collects the statistics of word, number, and character usage in a file (redirected as the standard input).


Create a subdirectory called proj1.

For this project you need to create at least two files: proj1.cpp, and makefile. Both files should be placed in the proj1 directory.

The file proj1.cpp should contain the main function, int main(). In the main() function, the program should read the input until it reaches the end, counting the number of times each word, number, and character is used. A word is defined as a sequence of letters ('a'..'z' or 'A'..'Z'). Words are case insensitive ("AA", "Aa", "aA", and "aa" are the same). A number is defined as a sequence of digits ('0'..'9'). Note that both words and numbers can be of length of 1, that is, contain one letter or one digit, respectively. Different sequences represent different numbers. For example, number "001" is different from number "1". Words are separated by numbers or other non-letter and non-digit characters. Numbers are separated by words or other non-letter and non-digit characters. Your program should record the number of times each word, number, and character happens (note that characters are case sensitive). The program should then output the ten most used characters (case sensitive), the ten most used numbers, and the ten most used words (case insensitive) as well as the number of times these characters/numbers/words are used. Since words are case insensitive, the program only outputs lower case words. The characters, numbers and words should be outputted in the descending order based on the number of times they are used. When two characters happen in the same number of times, the character with a smaller ASCII value should be considered as being used more frequently. When two words (numbers) happen in the same number of times, the word (number) that occurs earlier in the input should be considered as being used more frequently.

An example executable code of the program proj1.x is provided to you. In proj1.x, the output related to the display of characters, words, and numbers is aligned in the following manner: the width of the column of the characters, words, and numbers is the length of the longest words and numbers to be displayed, plus five (5). You should make the outputs of your program the same as those of 'proj1.x'. When printing characters, use '\t' for tab and '\n' for newline. All other characters should be outputted normally.

Write a makefile for your project that compiles an executable called proj1.x

You are encouraged to use any C++ STL containers and algorithms. You should also use C++ string class instead of the built-in string type.

Your program must be able to compile and run on linprog.

Example executable code

Click here to download the example executable code and 4 test cases. The executable code was compiled on a linprog machine. One bonus point is given to the first student who identifies a problem in the example executable code (no known problems with the provided code).

You need to redirect one of the test case files as the standard input to the executable code, for example:

proj1.x < test0

Please note that this run of the project uses Unix I/O redirection, which should have been discussed in an early class and also in our recitation. If you are not familiar with Unix I/O redirection, please refresh the concept yourself or ask for help. In particular, please note that, given that we are using I/O redirection, you do NOT need to open an input file in your program. You should read from standard input (such as cin) and write to the standard output (such as cout). You do NOT open any test file such as test0 in your program.
A really simple example.
$ cat proj.cpp
#include <iostream>
int main ( ) {
    std::cout << "Hello world\n";
$ cat Makefile 
# This is a makefile
proj.exe : proj.cpp
	$(CXX) -o $@ $?
$ make
g++ -o proj.exe proj.cpp
$ make
make: 'proj.exe' is up to date.

Note that the indentation for the $(CXX) line must be a real TAB character (0x09), not spaces.
silentwave wrote:
Wow thanks a lot for this example! I had similar problem and didn't know what to do. I even visit the website https://N O P E .com/ and wanted to ask there but Google finds me this topic. Thanks a lot because I'm not a essay writing service genius or something like that.

Seriously, is this how they are going to advertise now? Sucks man.
Topic archived. No new replies allowed.