Go Premium for a chance to win a PS4. Enter to Win


code check please

Posted on 2004-09-23
Medium Priority
Last Modified: 2010-04-01
Need help with lab homework:

# Makefile:
#        It uses the C++ Compiler with all warnings and
#        full debugging; will create a single executable called 'main'
# ---------------------------------------------------------------
# Note: If you want to use the g++ compiler on pegasus or helios
# uncomment the g++ lines and comment the Digital Unix lines

# the Digital Unix C++ compiler needs these lines:
CPP = cxx
CFLAGS = -L/usr/lib/cmplrs/cxx -DPOSIX_4D9 -w0 -gall

# the g++ compiler on pegasus and helios needs these lines:
# CPP = g++
# CFLAGS = -DPOSIX_4D9 -w -g

# link in the math library
LFLAGS = -lm

RM = rm -f
# ----------------------------------------------------------------
# Explanation of macros:
#     $< is any dependent file which is out of file1
#     $* is the target's basename (without extension)
#     $@ is the target's fullname
# add suffix .cpp since it is not a default with make util
.SUFFIXES:     .cpp .o
# implicit rule for compilation only:
     :{CPP} -c ${CFLAGS} $<

OFILES=          main.o

# dependencies
default:     main    
main:           $(OFILES)
     {CPP} ${CFLAGS} ${LFLAGS} $(OFILES) -o $@

main.o:          main.cpp

     ${RM} *.o
     ${RM} core
veryclean:     clean
     ${RM}  main  

#include <iostream>  
using namespace std;

#define CHUNK_SIZE 100

template <class item_t>
class Stack_t
    item_t*  items;
    int      top;

    Stack_t() : items(NULL), top(0) {}
    ~Stack_t() { delete [] items; }
    void push(item_t item)
        if (top%CHUNK_SIZE == 0)
            item_t* nitems = new item_t[top + CHUNK_SIZE];
            if (items != NULL)
                for (int i = 0; i < top; i++)
                    nitems[i] = items[i];
            delete []items;
            items = nitems;
        items[top++] = item;
    bool pop(item_t& item)
        if (top == 0)
            return false;
        item  = items[--top];
        if (top%CHUNK_SIZE == 0)
            item_t* nitems = NULL;
            if (top > 0)
                nitems = new item_t[top];
                for (int i = 0; i < top; i++)
                    nitems[i] = items[i];
            delete []items;
            items = nitems;
        return true;
    bool empty() { return top == 0; }

int main()
    const int SIZE = 100;
    Stack_t<char> S;
    char input[SIZE]    = { 0 };
    char S_output[SIZE] = { 0 };
    int i,length;
    cout << "Enter a palindrome> ";
    length = strlen(input);  
            cout << endl << "The words are not palindrome" << endl;
        else // if(Q_output[i]==S_output[i])
            cout << S_output[i];
    if (i >= length)
        cout << " is a palindrome" << endl;

    Stack_t<int> Si;
    int inp;
    cout << "Enter a list of integers terminated by -1" << endl;
    for (i = 1; ; ++i)
        cin >> inp;
        if (inp == -1)

    int sum = 0;
    while (!Si.empty())
        sum += inp;
    cout << "The sum of the numbers entered is " << sum << endl;
    return 0;


[edeloss2@pegasus lab2]$ make veryclean
rm -f *.o
rm -f core
rm -f  main
[edeloss2@pegasus lab2]$ make
:{CPP} -c -L/usr/lib/cmplrs/cxx -DPOSIX_4D9 -w0 -gall  main.cpp
/bin/sh: :{CPP}: not found
make: *** [main.o] Error 1

Question by:edelossantos
  • 2
LVL 16

Assisted Solution

PaulCaswell earned 2000 total points
ID: 12134638
So what works and what doesnt?

LVL 16

Accepted Solution

PaulCaswell earned 2000 total points
ID: 12134805
I am not terribly familliar with make files but this looks iffy:

     :{CPP} -c ${CFLAGS} $<

I'd suspect it should be

     {CPP} -c ${CFLAGS} $<


Author Comment

ID: 12134994
Finally....beautiful....that did it.  This one was tough and gave me a migrane and a lot of frustration.  Del

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question