|
CPallini wrote: esoteric
Is that the word?
I saw yours was a more general approach, but then I chose to leave the generalisation part to the OP.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Rajesh R Subramanian wrote: I chose to leave the generalisation part to the OP.
I think a simple Software Engineer can't be expected to be able to.
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: I think a simple Software Engineer can't be expected to be able to. [Big Grin]
You know, he has 2+ years of experience in VC++.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
hi..
Thank you its working fine..
now i want to append that attachment file to mail path...
Example my mail Path is
"https://testsrv1.ifit.com/Exchange/Administrator/Inbox">https://testsrv1.ifit.com/Exchange/Administrator/Inbox /ss.jpg"
I need to appen after Inbox/
first attachment file
example
"https://testsrv1.ifit.com/Exchange/Administrator/Inbox">https://testsrv1.ifit.com/Exchange/Administrator/Inbox/sample.jpg"...
Hi,,
I am sharan.Working as a software Engineer in Indo-Fuji Software Company located in BTM Layout.Bangalore.India.
I have Completed my B.E(COmputers)in 2006.ANd I am having 2 years of Exp in VC++.
thanking you
sharan
|
|
|
|
|
Well, you known, CString as a concatenation operator called + . Hence, for instance:
CString sPath = "MyFolder";
CString sMyAttachment = "sample.jpg";
sPath += "/" + sMyAttachment;
makes sPath equal to "MyFolder/sample.jpg".
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
|
|
|
|
|
hi ..
no Pallini...
i have my mail Path as
"https://testsrv1.ifit.com/Exchange/Administrator/Inbox">https://testsrv1.ifit.com/Exchange/Administrator/Inbox/Example.jpg"
I need to append my attachment file sample.jpg and remove that Example.jpz..
means i need to first get
"https://testsrv1.ifit.com/Exchange/Administrator/Inbox">https://testsrv1.ifit.com/Exchange/Administrator/Inbox/
then append sample.jpz to that ok.
thank you
Hi,,
I am sharan.Working as a software Engineer in Indo-Fuji Software Company located in BTM Layout.Bangalore.India.
I have Completed my B.E(COmputers)in 2006.ANd I am having 2 years of Exp in VC++.
thanking you
sharan
|
|
|
|
|
To remove the final part of the path (i.e. Example.jpg) use the (our friend Rajesh R Subramanian suggested) esoteric CString ReverseFind method (searching for the slash).
For instance
szPath = szPath.Left(szPath.ReverseFind('/'));
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
|
|
|
|
|
Hi..
If i want to print after Administrator then what to do
"https://testsrv1.ifit.com/Exchange/Administrator/Inbox">https://testsrv1.ifit.com/Exchange/Administrator/Inbox/Example.jpg"
//////////////////////////////////////////////////
I should get the result in this way
"https://testsrv1.ifit.com/Exchange/Administrator/Inbox">https://testsrv1.ifit.com/Exchange/Administrator/Example.jpg"
thank you
Hi,,
I am sharan.Working as a software Engineer in Indo-Fuji Software Company located in BTM Layout.Bangalore.India.
I have Completed my B.E(COmputers)in 2006.ANd I am having 2 years of Exp in VC++.
thanking you
sharan
|
|
|
|
|
I would suggest that you read up and experiment a little on CString . CString will give you everything that you need.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
See here [^].
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
|
|
|
|
|
Hi..
If i want to print after Administrator then what to do
"https://testsrv1.ifit.com/Exchange/Administrator/Inbox">https://testsrv1.ifit.com/Exchange/Administrator/Inbox/Example.jpg"
//////////////////////////////////////////////////
I should get the result in this way
"https://testsrv1.ifit.com/Exchange/Administrator/Inbox">https://testsrv1.ifit.com/Exchange/Administrator/Example.jpg"
Required to find /Inbox/Example.jpg
thank you
Hi,,
I am sharan.Working as a software Engineer in Indo-Fuji Software Company located in BTM Layout.Bangalore.India.
I have Completed my B.E(COmputers)in 2006.ANd I am having 2 years of Exp in VC++.
thanking you
sharan
|
|
|
|
|
Please do not post the same thing over and over. Try doing something yourself.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Here is an example*:
CString str = _T("Path/Old.jpg");
int iPos = str.ReverseFind('/');
str.Delete(iPos,str.GetLength()-iPos);
str += "/New.jpg";
AfxMessageBox(str);
*This example uses the esoteric ReverseFind() method.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
sharanu wrote: #Sample.jpg#TSXGMP850_EN_V10.pdf
Will the pattern of the string be same all the time? If it won't, then you may need to write a generalised approach.
Assuming that the pattern of the string will be the same, here is a way to do what you want:
CString str = _T("#Sample.jpg#TSXGMP850_EN_V10.pdf");
CString str1, str2;
int iPos = str.ReverseFind('#');
str2 = str.Mid(iPos+1);
str1 = str.Left(iPos);
str1.Remove('#');
AfxMessageBox(str1);
AfxMessageBox(str2);
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
If you are using MFC, see if AfxExtractSubString() will work for you.
"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
|
|
|
|
|
Can any one tell me that ..How to do Asynchronous Data Transfer through Serial Port.
Event based Serial communication,,,that means when any data come from serial port then,the particular function need to be called!!!!
the program does not wait long time for any data coming from Serial port.
Somebody suggested use callback functions!!!!!!but how?????
thanks in advance..
|
|
|
|
|
|
Hey everybody,
I'm using MS Visual C++ 6.0
I do have a code which contains classes in classes. Most inner class has a char** pointer which allocates memory using malloc function and adds a char array to string array.
To be more specific:
<br />
a = (char**) calloc(10, sizeof(char));
<br />
for (int i = 0; i < 10; i++)<br />
{<br />
a[i] = (char*) calloc(10 , sizeof(char));
}<br />
the problem is I want a destructor which free this array.
Says Access Violation each time I try to execute.
here is my code:
<br />
#include "stdafx.h"<br />
#include <malloc.h><br />
#include <stdio.h><br />
#include <conio.h><br />
<br />
<br />
class sub<br />
{<br />
public:<br />
char** a;<br />
<br />
sub();<br />
~sub();<br />
};<br />
<br />
<br />
sub::sub()<br />
{<br />
a = (char**) calloc(10, sizeof(char));<br />
<br />
for (int i = 0; i < 10; i++)<br />
{<br />
a[i] = (char*) calloc(10 , sizeof(char));<br />
}<br />
<br />
printf("\n%x - %x - %x\n", a[0], &a[0], *a[0]);<br />
};<br />
<br />
sub::~sub()<br />
{<br />
for (int i = 0; i < 50; i++)<br />
{<br />
char** A = a;<br />
char* Ai = a[i];<br />
char* Aii = (char *)*((int*)a[i]);<br />
<br />
free(a[i]);
}<br />
};<br />
<br />
<br />
class allocater<br />
{<br />
public:<br />
sub** subs;<br />
<br />
allocater();<br />
~allocater();<br />
<br />
};<br />
<br />
allocater::allocater()<br />
{<br />
subs = (sub**) calloc(10, sizeof(subs));<br />
int i; <br />
<br />
for (i = 0; i < 10; i++)<br />
{<br />
subs[i] = new sub();<br />
}<br />
};<br />
<br />
<br />
allocater::~allocater()<br />
{<br />
int i; <br />
<br />
printf("destructor allocater");<br />
<br />
for (i = 0; i < 10; i++)<br />
{<br />
delete subs[i];<br />
}<br />
};<br />
<br />
<br />
void main(int argc, char* argv[])<br />
{<br />
allocater** a = (allocater**) calloc(10, sizeof(allocater));<br />
int i;<br />
<br />
for (i = 0; i < 10; i++)<br />
{<br />
a[i] = new allocater();<br />
}<br />
<br />
printf("allocated");<br />
<br />
<br />
<br />
<br />
<br />
for (i = 0; i < 10; i++)<br />
{<br />
delete a[i];<br />
}<br />
<br />
<br />
printf("freed");<br />
<br />
getch();<br />
<br />
}<br />
Thank you everyone..
|
|
|
|
|
If you are writing C++ code (you are using classes, which is C++ specific), why do you still want to use C functions like malloc ? Prefer the use of new and delete instead.
|
|
|
|
|
dehseth wrote: sub::sub()
{
a = (char**) calloc(10, sizeof(char));
for (int i = 0; i < 10; i++)
{
a[i] = (char*) calloc(10 , sizeof(char));
}
printf("\n%x - %x - %x\n", a[0], &a[0], *a[0]);
};
sub::~sub()
{
for (int i = 0; i < 50; i++)
{
char** A = a;
char* Ai = a[i];
char* Aii = (char *)*((int*)a[i]);
free(a[i]); // crash point
}
};
you are allocating 10 items (for (int i = 0; i < 10; ) and freeing 50 items (for (int i = 0; i < 50; ) and what you are trying to achieve with char* Aii = (char *)*((int*)a[i]); and you are not freeing the first dimension array "a" in sub and in main(). I prefer you to learn the concepts clearly
|
|
|
|
|
Hi,
Like Cedric has mentioned you should try to use thew new and delete.
dehseth wrote:
a = (char**) calloc(10, sizeof(char)); // main array
for (int i = 0; i < 10; i++)
{
a[i] = (char*) calloc(10 , sizeof(char)); // char arrays
}
a has a size of 10 bytes (calloc(10, sizeof(char)) = 10 * 1 byte) but to
store 10 pointers you need 40 byte since a pointer has a 4 byte size (sizeof(int)).
Rewrite the allocation of a:
a = (char**) calloc(10, sizeof(int));
But again you should try to use the new and delete.
Learn from the mistakes of others, you may not live long enough to make them all yourself.
|
|
|
|
|
BadKarma wrote: a = (char**) calloc(10, sizeof(int));
what about sizeof (char *)
|
|
|
|
|
Good question.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
char* Aii = (char *)*((int*)a[i]);
What is This?
char* Aii = (char *)((int*)a[i]);
|
|
|
|
|