Char & String process - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Char & String process

heyyytheyyyt Posts: 10Member
Hello Friends,

I am a newbee on C and C++. I have a problem and I cannot find the solution.

Here is my function. My purpose is formatting the paramater, which is char pointer.
The formatting process must be in this form:
000ABBBCCCDD
A.BBB.CCC,DD
For example : 000102000099 -> 1.020.000,99

void CApp::FormatTheMoney(char *po_Money)
{
char *sTemp = new char[13];


sTemp[12] = po_Money[12]; // '' OR sTemp[12] = ''
sTemp[11] = po_Money[11];
sTemp[10] = po_Money[10];
sTemp[9] = ','; // ',' (Comma)
sTemp[8] = po_Money[9];
sTemp[7] = po_Money[8];
sTemp[6] = po_Money[7];
sTemp[5] = '.'; // '.' (Dot)
sTemp[4] = po_Money[6];
sTemp[3] = po_Money[5];
sTemp[2] = po_Money[4];
sTemp[1] = '.'; // '.' (Dot)
sTemp[0] = po_Money[3];

strcpy(po_Tutar, sTemp);

}


But this source has some mistakes. Whenever I run this program, program throws an Exception(Illegal instruction) on strcpy process line.

And when I traced the code I saw that sTemp had been never changed.

Thank you very much...

Comments

  • heyyytheyyyt Posts: 10Member
    Thank you for your interest.

    But I have just solved the problem. There are no bug in this code.(you can find some vulnerabilities, if you find please write here)

    This was a debug problem. The latest version of dll wouldn't been placed same directory with application. Because of this reason application can't see the new dll. And the interresting part of this problem was that debugger(Visual Studio 6.0 SP6) run the code which was newly created. (I don't know how it can be happened?)

    I asked this problem my friends too, and they answered me that sometimes debug information of application or dll files doesn't placed same directory of application!!!. -> This was not exact solution of my problem but it is really concerned with it.

    Re Thanks to you.

    : Hello Friends,
    :
    : I am a newbee on C and C++. I have a problem and I cannot find the solution.
    :
    : Here is my function. My purpose is formatting the paramater, which is char pointer.
    : The formatting process must be in this form:
    : 000ABBBCCCDD
    : A.BBB.CCC,DD
    : For example : 000102000099 -> 1.020.000,99
    :
    : void CApp::FormatTheMoney(char *po_Money)
    : {
    : char *sTemp = new char[13];
    :
    :
    : sTemp[12] = po_Money[12]; // '' OR sTemp[12] = ''
    : sTemp[11] = po_Money[11];
    : sTemp[10] = po_Money[10];
    : sTemp[9] = ','; // ',' (Comma)
    : sTemp[8] = po_Money[9];
    : sTemp[7] = po_Money[8];
    : sTemp[6] = po_Money[7];
    : sTemp[5] = '.'; // '.' (Dot)
    : sTemp[4] = po_Money[6];
    : sTemp[3] = po_Money[5];
    : sTemp[2] = po_Money[4];
    : sTemp[1] = '.'; // '.' (Dot)
    : sTemp[0] = po_Money[3];
    :
    : strcpy(po_Tutar, sTemp);
    :
    : }
    :
    :
    : But this source has some mistakes. Whenever I run this program, program throws an Exception(Illegal instruction) on strcpy process line.
    :
    : And when I traced the code I saw that sTemp had been never changed.
    :
    : Thank you very much...
    :
    :



Sign In or Register to comment.