|
|||
|
How do you dereference double quotes in C? I need to concatenate
double-quotes(") with a word so the result would be "word". I wrote something like: char *quote = malloc(sizeof(char)*2); quote = ""\0"; name = strcat(name,quote); name = strcat(name,word); name = strcat(name.quote); find(name); Word is a word taken as a command line argument. I need name to be the same as : char *name = "CProgramming"; Obviously I am doing something wrong. If someone could help me out I would greatly appreciate it. Thank you, Natalie |
|
|
||||
|
||||
|
|
|
|||
|
"lnatz" <nmrabinovich@gmail.com> wrote in message news:1160958452.056883.300760@k70g2000cwa.googlegr oups.com... > How do you dereference double quotes in C? I need to concatenate > double-quotes(") with a word so the result would be "word". I wrote > something like: > > char *quote = malloc(sizeof(char)*2); > quote = ""\0"; > name = strcat(name,quote); > name = strcat(name,word); > name = strcat(name.quote); > find(name); > > Word is a word taken as a command line argument. I need name to be the > same as : > > char *name = "CProgramming"; > > Obviously I am doing something wrong. If someone could help me out I > would greatly appreciate it. > "\"" "\"foo\"" > Thank you, > Natalie > |
|
|||
|
"lnatz" <nmrabinovich@gmail.com> wrote in message news:1160958452.056883.300760@k70g2000cwa.googlegr oups.com... > How do you dereference double quotes in C? I need to concatenate > double-quotes(") with a word so the result would be "word". I wrote > something like: > > char *quote = malloc(sizeof(char)*2); > quote = ""\0"; > name = strcat(name,quote); > name = strcat(name,word); > name = strcat(name.quote); > find(name); > > Word is a word taken as a command line argument. I need name to be the > same as : > > char *name = "CProgramming"; > > Obviously I am doing something wrong. If someone could help me out I > would greatly appreciate it. > "\"" "\"foo\"" > Thank you, > Natalie > |
|
|||
|
On Sun, 15 Oct 2006, lnatz wrote: > How do you dereference double quotes in C? I need to concatenate > double-quotes(") with a word so the result would be "word". I wrote > something like: > > char *quote = malloc(sizeof(char)*2); > quote = ""\0"; > name = strcat(name,quote); > name = strcat(name,word); > name = strcat(name.quote); > find(name); cr88192 has told you how to escape a double-quote in a string or character literal in C --- the same way you escape any other special character, with a backslash. (Carmen miranda posted nonsense; ignore it.) But your post indicates that you don't know anything about C, which means you should be picking up a copy of Kernighan and Ritchie's "The C Programming Language" and reading it *starting with Chapter 1*. Don't try anything complicated until you understand how functions and variables work; and don't try anything with strings until you understand pointers. C is an unforgiving language that will not warn you if you try to do something dumb. If you want more help learning C, alt.comp.lang.learn.c-c++ is thataway <---- -Arthur |
|
|||
|
On Sun, 15 Oct 2006, lnatz wrote: > How do you dereference double quotes in C? I need to concatenate > double-quotes(") with a word so the result would be "word". I wrote > something like: > > char *quote = malloc(sizeof(char)*2); > quote = ""\0"; > name = strcat(name,quote); > name = strcat(name,word); > name = strcat(name.quote); > find(name); cr88192 has told you how to escape a double-quote in a string or character literal in C --- the same way you escape any other special character, with a backslash. (Carmen miranda posted nonsense; ignore it.) But your post indicates that you don't know anything about C, which means you should be picking up a copy of Kernighan and Ritchie's "The C Programming Language" and reading it *starting with Chapter 1*. Don't try anything complicated until you understand how functions and variables work; and don't try anything with strings until you understand pointers. C is an unforgiving language that will not warn you if you try to do something dumb. If you want more help learning C, alt.comp.lang.learn.c-c++ is thataway <---- -Arthur |
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Re: Double Quotes - Solved | Jules Bosch | Newsgroup comp.soft-sys.sas | 0 | 04-03-2006 08:45 PM |
| Re: Double Quotes | Jiann-Shiun Huang | Newsgroup comp.soft-sys.sas | 0 | 04-03-2006 08:13 PM |
| Re: Double Quotes | Venky Chakravarthy | Newsgroup comp.soft-sys.sas | 0 | 04-03-2006 08:01 PM |
| Re: Double Quotes | Jules Bosch | Newsgroup comp.soft-sys.sas | 0 | 04-03-2006 07:35 PM |
| Leading double quotes using DDE | Joey Morris | Newsgroup comp.soft-sys.sas | 0 | 06-17-2005 07:43 PM |