strings??

This is a discussion on strings?? within the C Programming forums, part of the General Programming Boards category; HI can anyone help here.. how do you get rid of a quote character like this "\", inside a string.. ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    19

    strings??

    HI can anyone help here.. how do you get rid of a quote character like this "\", inside a string..

    say i read a string in input then i want to escape the backslash character "\" inside a string.. how can i do that?

    cheers
    Atif.

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    14
    char c[10];
    int i = 0, int max;

    while ((c[i] = getc(stdin)) != '\n')
    {
    if (c[i] == ' \ \')
    QUOTE]there should be two \ inside the apostrophes '\\' [/QUOTE]
    continue;
    else
    i++;
    }
    max = i;
    i = 0;

    while (i<max)
    {
    printf("%c", c[i]);
    i++;
    }[
    Last edited by Drako; 04-09-2002 at 06:07 AM.

  3. #3
    Im a Capricorn vsriharsha's Avatar
    Join Date
    Feb 2002
    Posts
    192

    Thumbs up

    if (c[i] == ' \ ')
    I guess it should be '\\' rather than '\'....

    so the statement becomes...
    if(c[i]=='\\')
    ---
    ---
    ---


    Regards,
    Sriharsha.
    Help everyone you can

  4. #4
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    That's correct. The difference between "\" and '\' is that '\' is a character and "\" is a null-terminated string.

  5. #5
    Registered User
    Join Date
    Feb 2002
    Posts
    591
    what is the difference between "\" and "\0"

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >what is the difference between "\" and "\0"
    '\', '\0'
    and
    '\', '0', '\0'

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strings Program
    By limergal in forum C++ Programming
    Replies: 4
    Last Post: 12-02-2006, 03:24 PM
  2. Programming using strings
    By jlu0418 in forum C++ Programming
    Replies: 5
    Last Post: 11-26-2006, 08:07 PM
  3. Reading strings input by the user...
    By Cmuppet in forum C Programming
    Replies: 13
    Last Post: 07-21-2004, 07:37 AM
  4. damn strings
    By jmzl666 in forum C Programming
    Replies: 10
    Last Post: 06-24-2002, 03:09 AM
  5. menus and strings
    By garycastillo in forum C Programming
    Replies: 3
    Last Post: 04-29-2002, 12:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21