Click here to Skip to main content
15,881,882 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionModal vs Modeless dialog box Pin
msr_codeproject20-Jan-10 6:05
msr_codeproject20-Jan-10 6:05 
AnswerRe: Modal vs Modeless dialog box Pin
Richard MacCutchan20-Jan-10 6:08
mveRichard MacCutchan20-Jan-10 6:08 
AnswerRe: Modal vs Modeless dialog box Pin
Rajesh R Subramanian20-Jan-10 6:58
professionalRajesh R Subramanian20-Jan-10 6:58 
QuestionRaeding and parsing mails via POP3 Pin
VictorSotnikov20-Jan-10 4:52
VictorSotnikov20-Jan-10 4:52 
AnswerRe: Raeding and parsing mails via POP3 Pin
Richard MacCutchan20-Jan-10 5:47
mveRichard MacCutchan20-Jan-10 5:47 
AnswerRe: Raeding and parsing mails via POP3 Pin
Joe Woodbury20-Jan-10 9:48
professionalJoe Woodbury20-Jan-10 9:48 
AnswerRe: Raeding and parsing mails via POP3 Pin
Rozis20-Jan-10 14:06
Rozis20-Jan-10 14:06 
Questionproblem with stack structure implementation in C, plz help !!! Pin
hung2h20-Jan-10 3:14
hung2h20-Jan-10 3:14 
#include <stdio.h>

struct Element{
	int value;
	struct Element *next;
};

struct Stack{
	int length;
	struct Element *head;
};

struct Stack createStack(){
	struct Stack s;
	s.length = 0;
	s.head = NULL;
	return s;
}


void push(struct Stack *stack, int value){
	if (stack->head == NULL){
		struct Element e = {value, NULL};
		stack->head = &e;
	}
	else{
		struct Element e = {value, stack->head};
		stack->head = &e;
		printf("(%d,%d)", stack->head->value, stack->head->next->value);
		if (stack->head == stack->head->next)
			printf("same");
	}

	stack->length++;
}

int main(){
	struct Stack s = createStack();
	int i;
	for (i = 0; i < 10; i++)
		push(&s, i);
	return 0;
}

i m really having trouble while implement stack structure in C using pointer. here the problem is only with push function, lies on 2 lines:
struct Element e = {value, stack->head};<br />
		stack->head = &e;

it seems that after i assigned stack->head to &e, the e->next(which was assigned to stack->head before) changes to be same with stack->head. lines bellow print results. can someone explain why? and how to fix it. thanks !
AnswerRe: problem with stack structure implementation in C, plz help !!! Pin
Richard MacCutchan20-Jan-10 3:38
mveRichard MacCutchan20-Jan-10 3:38 
GeneralRe: problem with stack structure implementation in C, plz help !!! Pin
hung2h20-Jan-10 3:52
hung2h20-Jan-10 3:52 
GeneralRe: problem with stack structure implementation in C, plz help !!! Pin
hung2h20-Jan-10 4:07
hung2h20-Jan-10 4:07 
GeneralRe: problem with stack structure implementation in C, plz help !!! Pin
Tim Craig20-Jan-10 12:45
Tim Craig20-Jan-10 12:45 
GeneralRe: problem with stack structure implementation in C, plz help !!! Pin
hung2h20-Jan-10 17:57
hung2h20-Jan-10 17:57 
QuestionPostMessage vs SendMessage Pin
Caslen20-Jan-10 2:17
Caslen20-Jan-10 2:17 
AnswerRe: PostMessage vs SendMessage Pin
CPallini20-Jan-10 2:44
mveCPallini20-Jan-10 2:44 
GeneralRe: PostMessage vs SendMessage Pin
Caslen20-Jan-10 3:26
Caslen20-Jan-10 3:26 
GeneralRe: PostMessage vs SendMessage Pin
CPallini20-Jan-10 3:28
mveCPallini20-Jan-10 3:28 
GeneralRe: PostMessage vs SendMessage Pin
Caslen20-Jan-10 5:12
Caslen20-Jan-10 5:12 
GeneralRe: PostMessage vs SendMessage Pin
Joe Woodbury20-Jan-10 6:36
professionalJoe Woodbury20-Jan-10 6:36 
GeneralRe: PostMessage vs SendMessage Pin
Caslen20-Jan-10 9:08
Caslen20-Jan-10 9:08 
GeneralRe: PostMessage vs SendMessage Pin
Joe Woodbury20-Jan-10 9:46
professionalJoe Woodbury20-Jan-10 9:46 
Questionfind folder list on a root folder Pin
Game-point20-Jan-10 1:59
Game-point20-Jan-10 1:59 
QuestionRe: find folder list on a root folder Pin
David Crow20-Jan-10 2:50
David Crow20-Jan-10 2:50 
AnswerRe: find folder list on a root folder Pin
Richard MacCutchan20-Jan-10 2:50
mveRichard MacCutchan20-Jan-10 2:50 
AnswerRe: find folder list on a root folder Pin
Graham Breach20-Jan-10 2:54
Graham Breach20-Jan-10 2:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.