punctuation

This is a discussion on punctuation within the C Programming forums, part of the General Programming Boards category; Hi , I dont succed to do the following: I want to eliminate the double quote at the beginning of ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    39

    punctuation

    Hi ,

    I dont succed to do the following:

    I want to eliminate the double quote at the beginning of a word as I read it with fscanf function:

    What I did it :
    Code:
    while (!feof(filein))
    { 
        fscanf(filein,"%s",buffer);
        if( buffer[0]==' \" ')
          buffer[0]=' \0';
    {
    fprintf(fout,"%s \n",buffer);
    When I print the words , at the word with the double quote at the beginning, it is a blank , and then continue with the other words.

    like
    for
    they
    thought
    <----suppose to have the word HERE
    only
    Casey
    could
    get


    Thank you

    B.

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    you will have to post actual contents of the file, not what you think it should be.

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> When I print the words , at the word with the double quote at the beginning, it is a blank

    maybe it has something to do with this?

    >> buffer[0]=' \0';
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    Registered User vinit's Avatar
    Join Date
    Apr 2006
    Location
    India
    Posts
    39
    indeed
    Code:
     buffer[0]=' \0';
    causes buffer[0] to content NULL character indicating end of string.So does fprintf(); cause to print nothing or blank as at very beginning i.e. buffer[0] it receives NULL character i.e. end of string.

    Thanks & Regards
    Vinit

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,548
    > while (!feof(filein))
    See the FAQ
    http://faq.cprogramming.com/cgi-bin/...&id=1043284351
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help remove spaces + punctuation
    By spchehe in forum C++ Programming
    Replies: 10
    Last Post: 11-18-2010, 10:07 AM
  2. Replies: 5
    Last Post: 12-21-2007, 12:38 PM
  3. How can I include punctuation in a string?
    By jumpyg in forum C++ Programming
    Replies: 3
    Last Post: 04-17-2006, 07:49 PM
  4. Punctuation in a string
    By titleist_03 in forum C++ Programming
    Replies: 1
    Last Post: 12-08-2004, 02:13 PM
  5. stripping punctuation from input file stream
    By asdfasdfasdf in forum C++ Programming
    Replies: 4
    Last Post: 10-01-2002, 01:27 PM

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