C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 10-17-2008, 08:26 AM   #1
The wheel reinvent0^r
 
hauzer's Avatar
 
Join Date: Aug 2008
Location: Србија
Posts: 115
My little stack library - what do you think?

I made this library just for fun. It works perfectly. There is a C version with a structure named "STACK" and a C++ version with a class named "STACK". You can push anything onto the stack (including raw data) and than pop it back later. There is also an "empty" command to clear the stack. It was developed in DevCpp.

Please no flaming, I just want your comments.

Download
Code:
Table of contents

BIN--------|
|          DLL------|
|          |        C----|
|          |        |   libstackc.a
|          |        |   stackc.dll
|          |        |
|          |        C++--|
|          |            libstackcpp.a
|          |            stackcpp.dll
|          STATIC---|
|          |       libstackc.a
|          |       libstackcpp.a
|         stack.h
|         stack.hpp
|
EXAMPLE----|
|         stackexample.c
|         stackexample.cpp
|
SRC--------|
           C----|
           |    dll-----|
           |    |      Stack Library.dev
           |    |      stack.c
           |    |      stack.h
           |    |
           |    static--|
           |           Stack Library.dev
           |           stack.c
           |           stack.h
           |
           |
           C++--|
                dll-----|
                |      Stack Library.dev
                |      stack.cpp
                |      stack.hpp
                |
                static--|
                       Stack Library.dev
                       stack.cpp
                       stack.hpp
hauzer is offline   Reply With Quote
Old 10-17-2008, 08:31 AM   #2
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
My main question would be "why?" - at least in C++, stack would typically be best implemented as a template, which would make it a .h only implementation.

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 10-17-2008, 08:38 AM   #3
Ex scientia vera
 
Join Date: Sep 2007
Posts: 426
Quote:
Originally Posted by matsp View Post
My main question would be "why?" - at least in C++, stack would typically be best implemented as a template, which would make it a .h only implementation.

--
Mats
Why not, rather? The best exercise to learn is to code. Almost everything you can possibly due within a reasonable time-frame in your own home as a hobby has been done before. It's all about the learning experience.
__________________
"What's up, Doc?"
"'Up' is a relative concept. It has no intrinsic value."
IceDane is offline   Reply With Quote
Old 10-17-2008, 08:47 AM   #4
Mysterious C++ User
 
Join Date: Oct 2007
Posts: 14,099
I think it is painfully obvious that you're not a C++ dev, hauzer. The C++ implementation leaves a little to be desired.
And I would like to comment that you should not strip the names of the parameters from function prototypes.

I'm sorry, but seeing as you use C-style functions and methods, I think you better scrap the C++ version and focus on your C version or learn C++ a little better before you attempt.
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Old 10-17-2008, 08:48 AM   #5
The wheel reinvent0^r
 
hauzer's Avatar
 
Join Date: Aug 2008
Location: Србија
Posts: 115
Well, as IceDane said, I wrote it only to exercise myself, specificly in the pointer&memory area of C because I'm a little thin there. Maybe someone will find it as a good example, I don't know.

EDIT:
@Elysia: yeah, I know. I really didn't experiment with C++ features much, maybe it's time.
hauzer is offline   Reply With Quote
Old 10-17-2008, 08:51 AM   #6
Mysterious C++ User
 
Join Date: Oct 2007
Posts: 14,099
I see... then I can suggest that you learn new/delete, templates, possible smart pointers and vectors. It would probably make a much better class.
Oh and usually C++ devs use T* instead of T * because it's strictly typed. Just a thought, no need to change.
Good luck anyway.
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Old 10-17-2008, 09:01 AM   #7
The wheel reinvent0^r
 
hauzer's Avatar
 
Join Date: Aug 2008
Location: Србија
Posts: 115
Thanks everyone.
hauzer is offline   Reply With Quote
Reply

Tags
library, stack, stack library

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Stack Implementation and Exceptions audinue C Programming 4 06-22-2008 09:32 AM
error trying to compile stack program KristTlove C++ Programming 2 11-03-2003 06:27 PM
Stack planet_abhi C Programming 2 04-12-2003 04:22 AM
Stack functions as arrays instead of node pointers sballew C Programming 8 12-04-2001 11:13 AM
inputting line of text vs. integers in STACK sballew C Programming 17 11-27-2001 11:23 PM


All times are GMT -6. The time now is 01:35 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22