|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Creating a string
I am trying to create a string from two strings using the following code and getting the following code and getting the warning Code:
In file included from ./prgms/raytrac.cc:62:0: baselib/clorfncs.hh: In function ‘void pr_hmisc(FILE*, int)’: baselib/clorfncs.hh:494:21: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] Code:
char* vbMsg01a = "important message. Each level can assume that all"; const char* vbMsg01b = " lower levels are also printing"; strcat(vbMsg01a,vbMsg01b); const char* vbMsg01c; strcpy (vbMsg01c,vbMsg01a); I need to create a const char* vbMsg01c |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Quote:
Hence your code should be something like this: Code:
const char* vbMsg01d = vbMsg01a; char* vbMsg01e; strcpy(vbMsg01e,vbMsg01d); const char* vbMsg01c = vbMsg01e; |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Have you allocated memory for vbMsg01c before trying to store characters in it...
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Creating a blank string of a specified size | kristinu | UNIX for Dummies Questions & Answers | 4 | 01-19-2012 01:00 PM |
| Creating 12 digit string value | Pratik4891 | Shell Programming and Scripting | 16 | 09-27-2010 08:45 AM |
| Creating String from words in a file | deepakthaman | Shell Programming and Scripting | 5 | 09-15-2009 01:37 PM |
| creating a delimiter string | satish@123 | Shell Programming and Scripting | 0 | 05-21-2008 05:38 AM |
| creating folder when the string matches | maximas | Shell Programming and Scripting | 2 | 10-04-2007 07:24 AM |
|
|