🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2171

Question on DATA STRUCTURES

#2171
From: Molle Anthony
Date: Mon, 04 Mar 1996 04:15
63 lines
1600 bytes
Hi it's me again, the new guy to "C".

Here's a data structures problem. Can someone tell me why the code
below does not work.   Please be kind -- I get enough abuse from my
wife hahahaha!!

#include <stdio.h>
#include <conio.h>
#include <alloc.h>
#define VERS 1.0

int stack1_top;
int stack2_top;
char letter_retrieved;
int *stack1_ptr = &stack1_top;
int *stack2_ptr = &stack2_top;
void push(char letr);


typedef struct letter_tag
{
   char element;
   struct letter_tag *next;
} LETTER_TYPE;


main()
{
  

   
   do
   {
      letter_retrieved= getchar();
      push(letter_retrieved);
   } while (letter_retrieved !='\n');

   return;
}


void push(char letr)
{
   LETTER_TYPE *temp_ptr;
   temp_ptr=(LETTER_TYPE*)malloc(sizeof(LETTER_TYPE));
   if (temp_ptr==NULL)
   {
      printf("\nNot Enough Ram.");
      return;
   }
   temp_ptr->element = letr;
   temp_ptr->*next = temp_ptr;
   stack1_ptr = temp_ptr;
   stack1_ptr++;

   return;
}

Any help in reference to the above problem, or comments on improving
my STYLE would be greatly appreciated.

Anthony Molle
titan@odyssee.net
Technical Details
Message-ID: <4hdqop$8sd@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: titan@pegasus.odyssee.net (Molle Anthony)
Newsgroups: comp.lang.c.moderated
Subject: Question on DATA STRUCTURES
Date: 3 Mar 1996 22:15:21 -0600
Organization: Odyssee Internet
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4hdqop$8sd@solutions.solon.com>
Reply-To: titan@pegasus.odyssee.net
NNTP-Posting-Host: solutions.solon.com
X-Newsreader: Forte Free Agent v0.55