how to replace a char in char *

前端 未结 3 1552
梦谈多话
梦谈多话 2020-12-18 11:17

total newbie here. i was trying to replace a character in char * but my program gives error

#include 

int main(int argc, char **argv)
{
    c         


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-18 11:48

    The

    char *mystring ="love is alweys better yoe"
    

    makes mystring read-only

    you need to copy the string into a buffer before you can change it

    e.g.

    char mystring[128];
    strcpy( mystring , "love is alweys better yoe" );
    

提交回复
热议问题