Thread: stack program

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    96

    stack program

    Hi,

    I am working on a stack program and wanted to know that can we use "get function" with stack data structure?

    eg if I have list of int numbers and I want to get these numbers before pushing these numbers on a stack. Can I use get function as:

    int get(item);// function for geting item number/

    "int item;"
    //variable for holding item number/

    Also If I want a variable to hold more than 1 numbers, can I do this:

    int num=1,4,7,8,10 ?
    Regards,
    Last edited by student111; 11-16-2013 at 10:39 AM. Reason: correcting

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by student111
    I am working on a stack program and wanted to know that can we use "get function" with stack data structure?

    eg if I have list of int numbers and I want to get these numbers before pushing these numbers on a stack. Can I use get function as:

    int get(item);// function for geting item number/

    "int item;" //variable for holding item number/
    Where did you hear of this "get function"? In your understanding, what does this "get function" do?

    Quote Originally Posted by student111
    Also If I want a variable to hold more than 1 numbers, can I do this:

    int num=1,4,7,8,10 ?
    No, that is using the comma operator. The net effect would be equivalent to:
    Code:
    int num = 10;
    You probably should reach for a std::vector<int> or other container of int values.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    96
    Their was a function that we have used in C++ program eg. getch or library functions eg.

    "c=getchar();"

    Ok, so if I need to assign int values or numbers to a variable eg. "num", do I have to assign them each as:
    int num=2;
    int num=5;
    int num=10;

    Regards,
    Last edited by student111; 11-17-2013 at 01:42 AM. Reason: correction

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Explain me how the stack looks like for any C program
    By ckarthickit in forum C Programming
    Replies: 2
    Last Post: 06-10-2010, 03:42 PM
  2. Stack program
    By trishtren in forum C Programming
    Replies: 1
    Last Post: 10-01-2009, 01:47 PM
  3. Character stack ADT program
    By alice in forum C Programming
    Replies: 1
    Last Post: 07-05-2004, 04:30 AM
  4. stack program; revisited
    By sballew in forum C Programming
    Replies: 10
    Last Post: 10-25-2001, 01:45 PM
  5. Stack Program Here
    By Troll_King in forum C Programming
    Replies: 7
    Last Post: 10-15-2001, 05:36 PM