View previous topic :: View next topic |
Author |
Message |
sohailkhanonline
Joined: 06 Mar 2008 Posts: 35 Location: pakistan
|
string help |
Posted: Wed Apr 16, 2008 5:23 am |
|
|
how to copy
"1.0" in a string
if i do
Code: |
char text[4];
strcpy(text,""1.0""); |
the colors are not ok in CCS _________________ sohail khan |
|
![](templates/subSilver/images/spacer.gif) |
Matro Guest
|
|
Posted: Wed Apr 16, 2008 6:11 am |
|
|
Code: |
strcpy(text,"\"1.0\"");
|
Matro |
|
![](templates/subSilver/images/spacer.gif) |
Matro Guest
|
|
Posted: Wed Apr 16, 2008 6:13 am |
|
|
Code: |
strcpy(text,"""1.0""");
|
Also works.
Matro |
|
![](templates/subSilver/images/spacer.gif) |
sohailkhanonline
Joined: 06 Mar 2008 Posts: 35 Location: pakistan
|
|
Posted: Wed Apr 16, 2008 6:35 am |
|
|
Thanks Matro _________________ sohail khan |
|
![](templates/subSilver/images/spacer.gif) |
sohailkhanonline
Joined: 06 Mar 2008 Posts: 35 Location: pakistan
|
|
Posted: Wed Apr 16, 2008 6:38 am |
|
|
by the way..
how can we declare a pointer string in CCS
will this code work..
char *ptr;
ptr="MATRO ROCKS";
printf("%s",ptr);
its not yet working for me.... _________________ sohail khan |
|
![](templates/subSilver/images/spacer.gif) |
Matro Guest
|
|
Posted: Wed Apr 16, 2008 7:08 am |
|
|
The problem comes from this line :
The problems is that the string is in ROM and so a pointer isn't possible
2 solutions :
- 1) copy the string from ROM to RAM manually
Code: |
strcpy(ptr,"MATRO ROCKS");
|
- 2) ask the compiler to do so
Code: |
#device PASS_STRINGS = IN_RAM
...
ptr="MATRO ROCKS";
|
Matro |
|
![](templates/subSilver/images/spacer.gif) |
|