Click here to Skip to main content
15,919,749 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to copy null terminatd buffer Pin
Cedric Moonen8-May-08 2:34
Cedric Moonen8-May-08 2:34 
GeneralRe: How to copy null terminatd buffer Pin
Rajesh R Subramanian8-May-08 2:36
professionalRajesh R Subramanian8-May-08 2:36 
GeneralRe: How to copy null terminatd buffer Pin
Cedric Moonen8-May-08 2:43
Cedric Moonen8-May-08 2:43 
GeneralRe: How to copy null terminatd buffer Pin
Rajesh R Subramanian8-May-08 2:45
professionalRajesh R Subramanian8-May-08 2:45 
GeneralRe: How to copy null terminatd buffer Pin
CPallini8-May-08 2:49
mveCPallini8-May-08 2:49 
GeneralRe: How to copy null terminatd buffer Pin
Rajesh R Subramanian8-May-08 2:54
professionalRajesh R Subramanian8-May-08 2:54 
QuestionRe: How to copy null terminatd buffer Pin
CPallini8-May-08 2:35
mveCPallini8-May-08 2:35 
AnswerRe: How to copy null terminatd buffer Pin
Rajesh R Subramanian8-May-08 2:33
professionalRajesh R Subramanian8-May-08 2:33 
memcpy should work. Anyways, I want you to get an idea of what, this problem is all about. If you know the length of the string, then something like this might work for you. This is just a rough idea, you might want to make it better and more secure:
#include "stdio.h"

void strcpyEx(char* dest, const char* source, int iLen)
{
    int i;
    for(i=0;i<iLen;++i)
    {
        dest[i] = source[i];
    }

}
int main()
{
    char a[] = {'\0','\0','H','i','\0'};
    char b[5];

    strcpy(b,a);
    printf("Attempting strcpy... b[3] is %d\n",b[3]);

    strcpyEx(b,a,4);
    printf("Attempting strcpyEx... b[3] is %d\n",b[3]);

    return 0;
}


Smile | :)
GeneralRe: How to copy null terminatd buffer Pin
CPallini8-May-08 2:46
mveCPallini8-May-08 2:46 
GeneralRe: How to copy null terminatd buffer Pin
Rajesh R Subramanian8-May-08 2:47
professionalRajesh R Subramanian8-May-08 2:47 
GeneralThank you all for the replies - I got it working :) Pin
Programm3r8-May-08 2:54
Programm3r8-May-08 2:54 
AnswerRe: How to copy null terminatd buffer Pin
David Crow8-May-08 3:43
David Crow8-May-08 3:43 
JokeRe: How to copy null terminatd buffer [modified] Pin
CPallini8-May-08 3:57
mveCPallini8-May-08 3:57 
GeneralRe: How to copy null terminated buffer Pin
Programm3r8-May-08 4:21
Programm3r8-May-08 4:21 
JokeRe: How to copy null terminatd buffer Pin
Nelek8-May-08 11:23
protectorNelek8-May-08 11:23 
Question[Message Deleted] Pin
Mohanraj D8-May-08 1:38
Mohanraj D8-May-08 1:38 
AnswerRe: error in MFC Pin
Cedric Moonen8-May-08 1:41
Cedric Moonen8-May-08 1:41 
GeneralRe: error in MFC Pin
Iain Clarke, Warrior Programmer8-May-08 3:18
Iain Clarke, Warrior Programmer8-May-08 3:18 
AnswerRe: [Message Deleted] Pin
Hamid_RT8-May-08 5:29
Hamid_RT8-May-08 5:29 
QuestionMail Proxy Pin
Anubhava Dimri8-May-08 1:16
Anubhava Dimri8-May-08 1:16 
AnswerRe: Mail Proxy Pin
Rajesh R Subramanian8-May-08 1:26
professionalRajesh R Subramanian8-May-08 1:26 
JokeRe: Mail Proxy Pin
Cedric Moonen8-May-08 1:27
Cedric Moonen8-May-08 1:27 
GeneralRe: Mail Proxy Pin
cp98768-May-08 2:08
cp98768-May-08 2:08 
AnswerRe: Mail Proxy Pin
Cranky8-May-08 2:36
Cranky8-May-08 2:36 
GeneralRe: Mail Proxy Pin
Anubhava Dimri8-May-08 2:52
Anubhava Dimri8-May-08 2:52 

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.