If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > i am a biggner of C, and i needs help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-09-04, 10:42
william629 william629 is offline
Registered User
 
Join Date: Feb 2004
Posts: 1
Unhappy i am a biggner of C, and i needs help

i am doing a question in C , and it needs me to print the comments in for a .c file, for example , if the file is like

#include "stack.h"

#define STACK_CAPACITY 100


struct stack {
int *array;
int stack_top;
};

//<LOOK! "objects" "Allocate an object using malloc, then return a pointer">
struct stack *
stack_new()
{
//<LOOK! "casts" "malloc returns a void pointer. Cast to desired type" 2>
struct stack *s = (struct stack *)malloc(sizeof(struct stack));
s->array = (int *)malloc(STACK_CAPACITY * sizeof(int));
s->stack_top = 0;
return s;
}

int
stack_empty(struct stack *s)
{
return s->stack_top == 0;
}

int
stack_full(struct stack *s)
{
return s->stack_top == STACK_CAPACITY-1;
}

void
stack_push(struct stack *s, int n)
{
s->array[(s->stack_top)++] = n;
}

int
stack_pop(struct stack *s)
{
return s->array[--(s->stack_top)];
}

//<LOOK! "objects" "allways provide method to free."
void
stack_free(struct stack *s)
{
free(s->array);
free(s);
}



after , it asked to print out the comments like this format:


casts
./stack.c 23 24 malloc returns a void pointer. Cast to desired type


objects
./stack.c 19 27 Allocate an object using malloc, then return a pointer
./stack.c 54 59 allways provide method to free.



anyone can give a help on this or give me some ideas , thanks!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On