Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.* 1 > Newsgroup comp.lang.misc

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 10-16-2006, 12:27 AM
lnatz
Guest
 
Posts: n/a
Default dereferencing double-quotes in C

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

Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 10-16-2006, 12:51 AM
cr88192
Guest
 
Posts: n/a
Default Re: dereferencing double-quotes in C


"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
>



Reply With Quote
  #3 (permalink)  
Old 10-16-2006, 12:51 AM
cr88192
Guest
 
Posts: n/a
Default Re: dereferencing double-quotes in C


"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
>



Reply With Quote
  #4 (permalink)  
Old 10-16-2006, 01:00 AM
carmen miranda
Guest
 
Posts: n/a
Default Re: dereferencing double-quotes in C



char *quote = malloc(2); /* a char type is the default
printf("\"%s\","\"%s\"name, quote);


Reply With Quote
  #5 (permalink)  
Old 10-16-2006, 01:00 AM
carmen miranda
Guest
 
Posts: n/a
Default Re: dereferencing double-quotes in C



char *quote = malloc(2); /* a char type is the default
printf("\"%s\","\"%s\"name, quote);


Reply With Quote
  #6 (permalink)  
Old 10-16-2006, 03:04 AM
Arthur J. O'Dwyer
Guest
 
Posts: n/a
Default Re: dereferencing double-quotes in C


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
Reply With Quote
  #7 (permalink)  
Old 10-16-2006, 03:04 AM
Arthur J. O'Dwyer
Guest
 
Posts: n/a
Default Re: dereferencing double-quotes in C


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
Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


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



All times are GMT. The time now is 01:52 PM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.