Solved

HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Posted on 2004-09-23
6
255 Views
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.o:
      :{CPP} -c ${CFLAGS} $<

OFILES=          main.o

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

main.o:          main.cpp

#
clean:
      ${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;

public:
    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> ";
    gets(input);
    for(i=0;input[i]!=NULL;i++)
    {
        S.push(input[i]);
    }
   
    length = strlen(input);  
    for(i=0;i<length;i++)
    {
        S.pop(S_output[i]);
       
        if(input[i]!=S_output[i])
        {
            cout << endl << "The words are not palindrome" << endl;
            break;  
        }
       
        else // if(Q_output[i]==S_output[i])
            cout << S_output[i];
    }
    if (i >= length)
        cout << " is a palindrome" << endl;
   
    putchar('\n');

    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)
            break;
        Si.push(inp);
    }

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

output:

[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

****************************NEED THIS BEHAVIOR...SHOW ME OR TELL ME HOW!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Enter a palindrome: madam

                The word reversed is: madam

                Enter a list of integers followed by -1: 1 2 3 4 5 -1

                The sum of the numbers on the stack is: 15

OR IS THIS CODE LIKE THIS ALREADY....IF YOU HAVEN'T FIGURED IT OUT...I AM CLUELESS....PLEASE, PLEASE, ADVISE!!!



0
Comment
Question by:edelossantos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 

Author Comment

by:edelossantos
ID: 12134461
ANYONE OUTHERE....AN ANWER ONE WAY OR ANOTHER WOULD WORK!!!!!!
0
 
LVL 11

Assisted Solution

by:griessh
griessh earned 250 total points
ID: 12134753
Hi edelossantos,

It looks like you are working on pegasus. Check these line and change the settings:

> # 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


======
Werner
0
 
LVL 11

Accepted Solution

by:
avizit earned 250 total points
ID: 12134781
>>>:{CPP} -c -L/usr/lib/cmplrs/cxx -DPOSIX_4D9 -w0 -gall  main.cpp


>>>/bin/sh: :{CPP}: not found <<<<------------------look what this error is

and loook at your Makefile


.cpp.o:
     :{CPP} -c ${CFLAGS} $<


++++++++++++++++
if you cant figure it out , read this

http://www.eng.hawaii.edu/Tutor/Make/   




0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:edelossantos
ID: 12134855
# 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.o:
      :{CPP} -c ${CFLAGS} $<

OFILES=          main.o

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

main.o:          main.cpp

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

[edeloss2@pegasus lab2]$ make
:{CPP} -c -DPOSIX_4D9 -w -g  main.cpp
/bin/sh: :{CPP}: not found
make: *** [main.o] Error 1

0
 
LVL 11

Assisted Solution

by:avizit
avizit earned 250 total points
ID: 12134946
as i said

++++++++++++++++++++
# implicit rule for compilation only:
.cpp.o:
     :{CPP} -c ${CFLAGS} $<

+++++++++++++++++++++++++

the lines above has errors  find it and fix , its simple enough and you should be able to fix it.

also the errors says
>>>>/bin/sh: :{CPP}: not found


that should give you a hint ..


0
 

Author Comment

by:edelossantos
ID: 12135017
That did it...I got it...finally...this code as all codes exceeded my limitations; however, it runs beautifully and finally to expectations and specifications.  A million thanks.  Del
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

737 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