Lost Password?

Go Back   CodeCall Programming Forum > Software Development > C and C++

Vote on your favorite hash algorithm here!

C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-01-2008, 04:04 PM
bladactania bladactania is offline
Newbie
 
Join Date: Apr 2008
Posts: 9
Credits: 0
Rep Power: 0
bladactania is on a distinguished road
Default Strange Characters.

I'm writing a program that analyzes a given text file counting occurrences of each unique word. I've got it working except some nagging weird characters in a text file I downloaded to test my program with. I've got the following function that determines of an "end-of-word" character has been found :

Code:
/* Checks character and determines if it is a word-ending character */
int isWordEnding (char inChar) {
  char endingChars[] = ",.!?()\":; \t[]{}_/\\\n*><#";
  int x, y;
  
  y = 0;

  for (x = 0; x < 23; x++) {
    if (inChar == endingChars[x]) {
      y = 1;
      break;
    }
  }
  
  return y;
}
It works very well. but for the following text, I somehow still get new line characters, but only for at the end of the second and third line.

PRINCESS OF FRANCE. We arrest your word.

Boyet, you can produce acquittances

For such a sum from special officers

Of Charles his father.

KING. Satisfy me so.

I've physically typed the same characters again and the program parses the words without any glitch. I've pasted the above text into MS Word and it just reads a new line and 4 spaces. Are there some other weird characters I don't know about?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 04-01-2008, 04:06 PM
bladactania bladactania is offline
Newbie
 
Join Date: Apr 2008
Posts: 9
Credits: 0
Rep Power: 0
bladactania is on a distinguished road
Default Re: Strange Characters.

oops. Sorry for double posting
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-03-2008, 08:09 AM
nutario's Avatar   
nutario nutario is offline
Newbie
 
Join Date: Mar 2008
Location: Germany
Posts: 23
Credits: 0
Rep Power: 3
nutario is on a distinguished road
Send a message via ICQ to nutario Send a message via Skype™ to nutario
Default Re: Strange Characters.

Well. It is not directly your question but I have a suggestion for your function:
Insert a else condition for more safety and for a clear code:
else {y = 0;}


To the new lines in your file: I thiink you got all posible chars. Perhaps, you should try to write the flie with an editor like vim or textpad (if you are using Windows).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Storing characters in an array John C and C++ 3 03-04-2008 12:06 AM
read characters from buffered reader random guy Java Help 2 12-02-2007 03:26 PM
Strange but i need it. mandriva Website Design 4 11-10-2007 11:29 AM
Strange DLL Error, creating controls ChrisPepper1989 C and C++ 0 02-26-2007 04:37 PM
Arabic Characters Frantic PHP Forum 0 11-07-2006 07:42 PM


All times are GMT -5. The time now is 10:51 AM.

Contest Stats

Xav ........ 1357.94
MeTh0Dz|Reb0rn ........ 1087.45
WingedPanther ........ 919.18
morefood2001 ........ 909.18
marwex89 ........ 906.86
John ........ 902.37
Brandon W ........ 789.89
chili5 ........ 312.39
Steve.L ........ 264.99
dcs ........ 240.34

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 83%

Ads