Click here to Skip to main content
15,887,683 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Display colour depth - what's the point? Pin
Taka Muraoka21-Sep-05 6:23
Taka Muraoka21-Sep-05 6:23 
QuestionInstall Project Pin
el_dude21-Sep-05 3:35
sussel_dude21-Sep-05 3:35 
AnswerRe: Install Project Pin
Blake Miller21-Sep-05 4:13
Blake Miller21-Sep-05 4:13 
QuestionMessage window scrolling Pin
Member 222024521-Sep-05 3:17
Member 222024521-Sep-05 3:17 
AnswerRe: Message window scrolling Pin
David Crow21-Sep-05 3:19
David Crow21-Sep-05 3:19 
GeneralRe: Message window scrolling Pin
ddmcr21-Sep-05 3:54
ddmcr21-Sep-05 3:54 
GeneralRe: Message window scrolling Pin
ddmcr21-Sep-05 3:58
ddmcr21-Sep-05 3:58 
Questionchar* problem Pin
ddmcr21-Sep-05 3:06
ddmcr21-Sep-05 3:06 
Hi everyone,
I am having following problem.

I have a function
char* foo()
{
	char c[ARRAY_SIZE] = "some text";
	return  c;
}


and now i want to print the text this function returns

int _tmain(int argc, _TCHAR* argv[])
{
 char * tmp =foo();	

 for(int i=0; i<ARRAY_SIZE; i++)
 {
        cout<<*(tmp);
	tmp++;
 }
return 0;
}


and in output i get text where first symbols is 's' and other's are
some other strange symbols.

In debugger i see that tmp really points at the text
tmp (0x0012fdd4 "some text")
, but right after the cout operator is invoked tmp changes its value to strange symbols D'Oh! | :doh:

What am i doing wrong???

thanks for help Smile | :)




"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill



-- modified at 9:07 Wednesday 21st September, 2005


AnswerRe: char* problem Pin
David Crow21-Sep-05 3:11
David Crow21-Sep-05 3:11 
GeneralRe: char* problem Pin
ddmcr21-Sep-05 3:26
ddmcr21-Sep-05 3:26 
GeneralRe: char* problem Pin
David Crow21-Sep-05 3:54
David Crow21-Sep-05 3:54 
GeneralRe: char* problem Pin
Blake Miller21-Sep-05 4:20
Blake Miller21-Sep-05 4:20 
GeneralRe: char* problem Pin
David Crow21-Sep-05 4:33
David Crow21-Sep-05 4:33 
GeneralRe: char* problem Pin
Blake Miller21-Sep-05 5:00
Blake Miller21-Sep-05 5:00 
GeneralRe: char* problem Pin
David Crow21-Sep-05 6:37
David Crow21-Sep-05 6:37 
GeneralRe: char* problem Pin
Blake Miller21-Sep-05 6:45
Blake Miller21-Sep-05 6:45 
GeneralRe: char* problem Pin
Blake Miller21-Sep-05 6:49
Blake Miller21-Sep-05 6:49 
AnswerRe: char* problem Pin
Nish Nishant21-Sep-05 3:11
sitebuilderNish Nishant21-Sep-05 3:11 
AnswerRe: char* problem Pin
mikeorama1234522-Sep-05 6:41
mikeorama1234522-Sep-05 6:41 
QuestionMoving controls on a dialog Pin
bugDanny21-Sep-05 2:56
bugDanny21-Sep-05 2:56 
AnswerRe: Moving controls on a dialog Pin
David Crow21-Sep-05 3:12
David Crow21-Sep-05 3:12 
AnswerRe: Moving controls on a dialog Pin
prasad_som21-Sep-05 3:15
prasad_som21-Sep-05 3:15 
GeneralRe: Moving controls on a dialog Pin
andrewtruckle21-Sep-05 3:23
andrewtruckle21-Sep-05 3:23 
AnswerRe: Moving controls on a dialog Pin
Rage21-Sep-05 3:18
professionalRage21-Sep-05 3:18 
GeneralRe: Moving controls on a dialog Pin
bugDanny21-Sep-05 4:56
bugDanny21-Sep-05 4:56 

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.