Solved

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

Posted on 2004-09-23
6
250 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
  • 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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 video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now