Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- /* This is a template with the functions you must implement for this assignment.
- *
- * Note that you are free to implement any additional function you consider appropriate.
- *
- */
- struct stack_value{
- char value;
- struct stack_value *next;
- };
- struct stack_value *Head = NULL;
- // push a character into the stack
- void stack_push(char c){
- printf("beginning\n");
- struct stack_value *temp = malloc(sizeof(struct stack_value));
- temp->value = c;
- temp->next = Head;
- Head = temp;
- printf("%i\n",c );
- printf("end\n");
- }
- /* Overwrites the character pointed by c with the character currently on
- * top of the stack.
- *
- * The function returns 0 if the operation can be carried out successfully,
- * and any non-zero number if the operation could not be performed (for instance
- * because the stack is empty).
- */
- int stack_top(char *c){
- if(Head == NULL)
- return 1;
- else{
- *c = (Head->next)->value;
- printf("%i\n",*c );
- return 0;
- }
- }
- /* Overwrites the character pointed by c with the character currently on
- * top of the stack, and removes the character from the top of the stack.
- *
- * The function returns 0 if the operation can be carried out successfully,
- * and any non-zero number if the operation could not be performed (for instance
- * because the stack is empty).
- */
- int stack_pop(char *c){
- if(Head == NULL)
- return 1;
- *c = (Head->next)->value;
- struct stack_value *temp;
- temp = Head;
- Head = Head->next;
- return 0;
- }
- /* Returns a dynamically allocated string (in the heap)
- * containing the characters in the string pointed by source,
- * excluding any one-line comment.
- */
- char *remove_single_line_comment(const char *source){}
- /* Returns a dynamically allocated string (in the heap)
- * containing the characters in the string pointed by source,
- * excluding any multi-line comment.
- */
- char *remove_multi_line_comment(const char *source){}
- /* The main function of your program. Rename into mymain
- * for testing.
- */
- int mymain(int argc, char **argv) {
- //the code of your main function goes here.
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement