1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

what is the equivalent const char* in cobol

Discussion in 'C' started by ronald, Jun 15, 2009.

  1. ronald

    ronald New Member

    Joined:
    Jun 15, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi There,

    does anyone know the equivalent data type in cobol for const char* var in C?

    thanks
    R
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Which version of Cobol are you using (i.e. what compiler - include full details inc full version number and all that)?
     
  3. ronald

    ronald New Member

    Joined:
    Jun 15, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Microfocus 3.1 and I'm trying from Cobol to call a C++ dll which has a function with the following paramaters:
    char *sSQL
    const char *sDatabaseName.

    Please note that the calling itself is ok (return no error). however, the error occurs at the end of the cobol program.

    the following is the error:
    114 attempt to access item beyond bounds of memory (signal 11).

    If I tried to call only on char *sSQL (without const char *sDatabaseName) then it works.

    any clue?
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Going by the variable names they both look like input variables (i.e. input to the DLL function). What does the function do with results?

    The two variables will be represented the same way in the Cobol program; you can treat both as just char* and ignore the const. Const is just a contract that means the string won't be modified.

    Can you reproduce the problem with a short Cobol program (say 10 lines or so in the PROCEDURE DIVISION)?
     
  5. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,343
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    Hmm..:thinking:

    That can't be caused by a missing const. Your program might be trying to access array index(es) beyond its size.
    Could you please post your code.

    BTW, const char * is nothing special. It's just the same char *. The only thing the const keyword does it, it makes the target func aware that it should not alter the char *.
     

Share This Page