|
Cedric Moonen wrote: I suggest you use a std::string instead of plain char arrays,
Only if he was using C++.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Rajesh R Subramanian wrote: Only if he was using C++.
Errr.. yes. But as the title of the message board is Visual C++ and that he didn't specifically said he was working in C, I concluded he was using C++ (yeah I know, jumping a bit too fast on the conclusion )
|
|
|
|
|
Actually, I had been stupid enough to use things like cout in the solution I provided to him, even though I assumed it was C (just modified it to use printf ). We're addicted to C++, you see.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Rajesh R Subramanian wrote: We're addicted to C++
What are these two fancy symbols following the only Real Man's Language?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
CPallini wrote: What are these two fancy symbols following the only Real Man's Language?
Symbols of evolution.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Could you make a detailed example (of what you have and what do you want to obtain)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
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;
}
|
|
|
|
|
Some formatting reviewal needed.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Fixed, thanks.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
|
Programm3r wrote: I know memcpy will work but it will also wipe the data that is already in the buffer.
One of the basic rules of physics states that no two objects can occupy the same space. Of course memcpy() will wipe out the destination, but so will any other function.
While concatenation is a completely different subject, memcpy() can still be used.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: One of the basic rules of physics states that no two objects can occupy the same space.
Perhaps Mr.Bose and Mr.Einstein would remark on the above.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
modified on Thursday, May 8, 2008 11:13 AM
|
|
|
|
|
I was stating the obvious, and I believe so are you.
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
DavidCrow wrote: One of the basic rules of physics states that no two objects can occupy the same space
I think you forgot to add: "at the same time"
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
|
Mohanraj D wrote: what should be done??
First try to give a correct description of your problem because it doesn't make any sense (and read the posting guidelines at the top of this forum). What is the exact error ?
|
|
|
|
|
I have some sympathy for them deleting their mess - but I'm always curious to see just how bad the question was...
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
|
Hi All,
Can any one Help me regarding the Mail Proxy.
Thanks
anubhava Dimri
919250168195
|
|
|
|
|
May be.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Or maybe not... Who knows
|
|
|
|
|
I think the answer is almost certainly yes, afterall the question was "Can any one Help me regarding the Mail Proxy". As to whether 'anyone' is here or is watching is another question.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
Member 4542257 wrote: 919250168195
Is this your phone number?
|
|
|
|
|
|