473,321 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Problrm with punc in C

I am writing a very simple program which suppose to get a text froma file and then by ignoring all the spaces and punctuation, copy them to another file , 1 word per line.
my problem is i cant get my program to ignore the punctuations.
my code is::
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. int main(void)
  3. {
  4.      int charac;
  5.       int count=0;
  6.  
  7.    while((charac=getchar()) !=EOF)
  8. {
  9.   if( (charac>47 && 58>charac) || (charac>40 && 91>charac) || (charac>96     && 123>charac) )
  10.    {
  11.          putchar(charac);
  12.          count=1;
  13.  
  14.    }
  15.    else
  16.    {
  17.        if(count==1)
  18.        {
  19.        putchar(10);
  20.        count++;
  21.        continue;
  22.  
  23.        }
  24.        else
  25.            continue;
  26.    }
  27. }
  28.  
  29. return 0;
  30. }
  31.  
I've used the ASCII for checking.
now how can i get my program to ignore the punctuations.What is my problem?
The input is like:
blah blah blah, blah.
My output is like:
blah
blah
blah,
blah.
It suppose to be like:
blah
blah
blah
blah
Mar 2 '08 #1
1 1308
weaknessforcats
9,208 Expert Mod 8TB
Ib <ctype.h> there is a function ispunct() that returns true of your character is a punctuation character.

Use this as the test in your if statement.
Mar 2 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ron | last post by:
The C++ standard ISO/IEC 14882 specifies pp-numbers as follow: pp-number: digit .digit pp-number digit pp-number nondigit pp-number e sign pp-number E sign pp-number .
7
by: truedos | last post by:
hello, I have a text file that looks like this: text numbers text numbers text numbers .. ..
0
by: Sara T. | last post by:
When I use CheckBox as a webcontrol (Server Control), I found that I cannot set it to left align. Like this: This is a label This is my check box I need to see CheckBox on the position...
0
by: Stephen | last post by:
I created a form that reads a access file.... Works well but i cant get the yes/no field in the database to bind to a series of checkboxs... when i do a data preview on the data Adapter they are...
0
by: Andrew Baker | last post by:
I have a MDI parent which is to open a "Control Panel" style child when it starts. In the load event I have: Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As...
6
by: mathieu.malaterre | last post by:
Hello, I cannot figure out a way to find a regular expression that would match one and only one of these two strings: s1 = ' how are you' s2 = ' hello world ...
9
by: borophyll | last post by:
GCC allows you to define macros called "new" and "delete" in the preprocessor phase. This seems to be in violation of the C++ spec, in particular the rules for the creation of preprocessing...
0
by: sslaughter | last post by:
Hello ! I have new riddle for you :) Well i want to make tray icon (which is not a problem), but it have to handle MouseWheel Event (and it is not a simple task). Can you tell me how i could...
7
by: Alenik1989 | last post by:
i have this code which suppose to get a n input from the file and store it in a char array then i have to inverse it..... rhis code isnt complete but im getting a wiered error i see the error ...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.