Thread: help needed! string literals

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    36

    help needed! string literals

    I am new to C programming, i am currently working on a program where i must accept keyboard input and reproduce the text after eliminating white space. unless the text is in a string literal, then it must be reproduced with spaces. i have the first part (printing without spaces) but im not quite sure how to make it print normally within string literals....can anyone help me? here is my code

    Code:
    #include <stdio.h>
    
    int main()
    {
       int c;
       
       printf("This program eliminates whitespace from an input stream,\n");
       printf("except from within string literals in double quotes.\n");
       printf("\n");
       printf("Type characters, and enter EOF after <enter> to finish:\n");
       
       while ((c = getchar()) != EOF) 
          if ( c != ' ') 
          putchar(c);
          
       system("pause");
       return 0;
    }

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Dude, you previous thread was moved to the C programming board since the code is pure C and you yourself state you are learning C, not C++
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    Registered User
    Join Date
    Feb 2009
    Posts
    36
    sorry im new and i am using dev c++ so i thought thats what it was. sorry for the inconvenience

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. char Handling, probably typical newbie stuff
    By Neolyth in forum C Programming
    Replies: 16
    Last Post: 06-21-2009, 04:05 AM
  2. help! string literals
    By cakestler in forum C Programming
    Replies: 16
    Last Post: 02-05-2009, 11:41 AM
  3. Replies: 1
    Last Post: 05-30-2003, 02:31 AM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM