Memory violation error

Discussion in 'C' started by vijay_K, Feb 3, 2016.

  1. vijay_K

    vijay_K New Member

    Joined:
    Feb 3, 2016
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Getting memory violation error when i use string function "strlwr", what wrong in step 3, please help, I am new to c language

    char *a="SAM";
    char *c;
    c=strlwr(a);
    printf("%s",c);

    Thanks
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    You haven't initialised "a" correctly. Define it as an array of char, strcpy "SAM" into it, then strlwr should work as you expect.
     
  3. shibaa987

    shibaa987 New Member

    Joined:
    Feb 5, 2016
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Occupation:
    Device driver development
    Location:
    Bangalore, India
    Home Page:
    https://www.modapk.tv/
    You should initialize the char *a as following:
    char a[]="SAM";

    I believe this will just solve your problem.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice