cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
C++ Stacks Problem
C++ Stacks Problem
Apr 23, 2020 at 9:42pm UTC
Horror
(47)
How do I create a stack of type "char" with 100 elements?
Apr 23, 2020 at 9:53pm UTC
zapshe
(1988)
char
arr[100];
Any questions about this?
Apr 23, 2020 at 9:55pm UTC
Horror
(47)
I hate myself for not figuring that out. Thank you zapshe.
Last edited on
Apr 23, 2020 at 9:56pm UTC
Apr 23, 2020 at 10:09pm UTC
zapshe
(1988)
♥
Apr 23, 2020 at 10:24pm UTC
Ganado
(6849)
Just to be clear... that is not a "stack" in the sense of the classic data structure. That's just a regular array (but certainly could be used as a stack).
C++ has a stack class built-in.
http://www.cplusplus.com/reference/stack/stack/
See an example of pushing 5 elements to the stack below.
http://www.cplusplus.com/reference/stack/stack/push/
Last edited on
Apr 23, 2020 at 10:24pm UTC
Apr 23, 2020 at 10:26pm UTC
zapshe
(1988)
I assume he meant stack as in how the memory for the char would be handled. The way
char
arr =
new
char
[100]
would allocate to the heap.
Topic archived. No new replies allowed.