Click here to Skip to main content

C / C++ / MFC

 
AnswerRe: Casting structures - another basic question PinmvpRichard MacCutchan24-Dec-12 6:19 
GeneralSOLVED Casting structures - another basic question PinmemberVaclav_Sal24-Dec-12 9:04 
GeneralRe: SOLVED Casting structures - another basic question PinmemberErudite_Eric2-Jan-13 8:13 
QuestionHow to count pages in PDF file using VC++ Pinmembershanmugarajaa23-Dec-12 19:00 
AnswerRe: How to count pages in PDF file using VC++ PinmvpRichard MacCutchan23-Dec-12 23:04 
AnswerRe: How to count pages in PDF file using VC++ PinmemberJijo.Raj27-Dec-12 0:29 
QuestionHow to implement C++ raw string literals in VIsual C++ 2010? PinmemberFalconapollo22-Dec-12 19:03 
Questionproblems returning/printing poiner Pinmemberdoughyi8u20-Dec-12 15:16 
I understand that the reason the ret variable will not print (it's at the end of the string when destination is passed) but can't figure out how to return destination out of the my_strcpy() function. I can make this work using array notation but not pointer arithmetic. Here's the code in question:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char *my_strcpy(char *, const char *);
 
int
main()
{
	char *strA = "This is a string";
	char *strB;
	char *ret;
 
	strB = malloc(strlen(strA)+1);
	ret = my_strcpy(strB, strA);
	puts(ret);
	puts(strB);
	free(strB);
	return 0;
}
 
char *my_strcpy(char *destination, const char *source)
{
	while (*source != '\0')
	{
		*(destination++) = *(source++);
	}
	*destination = '\0';
	return destination;
}

AnswerRe: problems returning/printing poiner PinmemberJochen Arndt20-Dec-12 22:15 
AnswerRe: problems returning/printing poiner PinmvpRichard MacCutchan20-Dec-12 23:47 
GeneralRe: problems returning/printing poiner PinmemberJochen Arndt21-Dec-12 0:07 
GeneralRe: problems returning/printing poiner PinmvpRichard MacCutchan21-Dec-12 1:19 
QuestionC++ ownerdrawfixed combobox "header" PinmemberNoviceEx19-Dec-12 3:49 
AnswerRe: C++ ownerdrawfixed combobox "header" Pinmemberjeron119-Dec-12 5:19 
QuestionHow to make a project resolution independent.? Pinmembermbatra3119-Dec-12 0:56 
AnswerRe: How to make a project resolution independent.? PinmemberJochen Arndt19-Dec-12 1:29 
GeneralRe: How to make a project resolution independent.? Pinmembermbatra3119-Dec-12 1:39 
GeneralRe: How to make a project resolution independent.? PinmemberJochen Arndt19-Dec-12 1:52 
GeneralRe: How to make a project resolution independent.? Pinmembermbatra3119-Dec-12 2:25 
GeneralRe: How to make a project resolution independent.? PinmemberJochen Arndt19-Dec-12 2:33 
GeneralRe: How to make a project resolution independent.? Pinmembermbatra3119-Dec-12 2:44 
GeneralRe: How to make a project resolution independent.? PinmemberJochen Arndt19-Dec-12 3:06 
AnswerRe: How to make a project resolution independent.? PinmemberAlan Balkany19-Dec-12 5:25 
QuestionASM with stams library of C ++ PinmemberGurunathkudalkar18-Dec-12 22:15 
AnswerRe: ASM with stams library of C ++ PinmvpCPallini18-Dec-12 23:19 

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

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


Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 31 Mar 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid