• 0

How to count how many times a word appears in a .txt file


Question

11 answers to this question

Recommended Posts

  • 0

Why would you need a program to complete it? Surely the CTRL+F and Count would work better in Notepad++

 

Edit: or what @Nefarious Triggertrigger said :shiftyninja:

  • 0
  On 13/03/2017 at 14:04, fifikaki said:

Nefarious Trigger its a project but i have no idea what to do

Expand  

A school project? Neowin won't do your homework for you, but we can offer you guidance and point you in the right direction.

  • 0
  On 13/03/2017 at 14:12, fifikaki said:

I want to give me just an idea. Νot solve my project...maybe my question it was wrong. sorry

Expand  

I always started with pseudocode before going in to real coding. That way I had an idea of what I wanted to achieve. So let's start with that, what do you want the program to do? If you had to do the job yourself rather than creating a program, how would you count how many times a certain word appears?

  • Like 1
  • 0
  On 13/03/2017 at 14:12, fifikaki said:

 

I want to give me just an idea. Νot solve my project...maybe my question it was wrong. sorry

Expand  

So what self-driven learning have you undertaken so far?  I ask this because what you're asking is ridiculously easy, and I struggle to accept that you've even tried so far.

  • 0
  On 13/03/2017 at 13:43, anonymous_john said:

Hello! Ηow to create a program in C ++ where it counts how many times appears a specific word in a  txt file? Can someone help me?

Expand  

The problem with a question like this is we have no idea what's actually blocking you. Have you ever written any C++? Any program in any language? Do you know how to open a file in C++? Do you know how to compare strings?

 

Show us what you've done and what exactly is blocking you from making progress.

  • 0

 

  On 13/03/2017 at 14:35, winlonghorn said:

I would suggest Regular Expressions. Research MatchCollections with Regular Expressions in .NET. That should allow you to achieve what you want. Hopefully, that points you in the right direction.

Expand  

Yes regex is the solution, if you ever need to parse xml I highly suggest using regex :woot: 

But seriously, don't parse xml with regex, if you want to spend a whole summer debugging code go for it but I wouldn't recommend it, regex isn't designed to work well with nested tags neither is it made to do everything text related even when it could be done with a simpel for loop. Regex is useful as example if you don't want to search for just a word but for all words that start with neo and end with win.

 

He asked about c++ that's quite a bit different from .NET and all of it's libraries available for it.

.NET is like walking with 2 legs but c++ is not even like walking with 1 leg, it's more like having no legs at all in my experience :cry:

  • 0
  On 14/03/2017 at 05:02, Seahorsepip said:

 

Yes regex is the solution, if you ever need to parse xml I highly suggest using regex :woot: 

But seriously, don't parse xml with regex, if you want to spend a whole summer debugging code go for it but I wouldn't recommend it, regex isn't designed to work well with nested tags neither is it made to do everything text related even when it could be done with a simpel for loop. Regex is useful as example if you don't want to search for just a word but for all words that start with neo and end with win.

 

He asked about c++ that's quite a bit different from .NET and all of it's libraries available for it.

.NET is like walking with 2 legs but c++ is not even like walking with 1 leg, it's more like having no legs at all in my experience :cry:

Expand  

Sorry, I was reading in a hurry yesterday. I was trying to help out and work on a project for work at the same time. Probably wasn't the best idea. Thank you for your response! I agree about c++ btw. It can be rough! 

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Apple: lets take our inspiration from Windows 7/Vista and call it innovative
    • Nice! My $100 refurbished iPad 8 that I bought last year for a small project (and still runs like new cuz it's been mostly in storage the past several months) will get this v26 upgrade. I'm definitely gonna scope out OS26 on this device before upgrading my also-supported refurbished iPhone SE 3rd Gen (only got it for the 5G UW support).
    • Hello, The separate discussion about VLC has been moved to its own thread at  Regards, Aryeh Goretsky  
    • Hello, I am guessing this is the result of using a third-party tweaking tool instead of changing things within Windows settings. Windows 11 has a decent set of configuration options for the display, but they tend to be scattered throughout the operating system due to fragmentation of product ownership/inconsistent standards being applied by Microsoft. There are a few places in Windows 11 where you can modify the various display settings in order to get them to your liking: Under Settings → System → Display you can stroll down to the Scale & layout section and change the Scale and Display resolution settings to whatever you prefer.  For the Scale option, you can click on the text box to choose between the various pre-populated settings.  If none of those are exactly what you are looking for, click on the caret ("") caret to open the Custom scaling setting (also available under Settings → Display → Custom scaling).  I would recommend this as an option of last resort as this can cause display issues in various programs. I strongly recommend using the screen's native Display resolution here; it should show up as the "(Recommended)" resolution.  If it does not, you may need to install your monitor's profile information file (basically, a device driver for your monitor) to get the correct setting. Another place to look at making changes to fonts is under Accessiblity → Text size.  There is a slider bar for changing the text size from 100% to 225% there. You can try making changes to the ClearType settings.  It's a little bit finer-grained than the others, but it may make the text easier to view on the display.  Run the ClearType Text Tuner (filename: CTTUNE.EXE) and go through the wizard. You may want to do this several times under different lighting conditions or times of the day to figure out what works best for you overall. Lastly, you may want to look into using a dedicated assistive screen technology program from a third-party.  Microsoft provides a Screen Magnifier and a Narrator for text-to-speech, but they provide only basic functionality, and you may find that a third-party program works a lot better.  The pros of this is that third-party assistive technology programs tend to work quite well under Windows; Microsoft has historically worked closely with third-party developers of assistive technologies.  The cons of this are that such tools tend to be on the expensive side, since they are often sold to schools, businesses, or paid for by insurance companies, not individuals. Regards, Aryeh Goretsky  
    • Totally agree with you. I think people, especially on tech sites, need to realize that they’re the minority. Microsoft isn’t going to waste time on things that, in the big picture, don’t matter to the majority.
  • Recent Achievements

    • Dedicated
      MadMung0 earned a badge
      Dedicated
    • Rookie
      CHUNWEI went up a rank
      Rookie
    • Enthusiast
      the420kid went up a rank
      Enthusiast
    • Conversation Starter
      NeoToad777 earned a badge
      Conversation Starter
    • Week One Done
      VicByrd earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      506
    2. 2
      ATLien_0
      267
    3. 3
      +FloatingFatMan
      257
    4. 4
      Edouard
      203
    5. 5
      snowy owl
      178
  • Tell a friend

    Love Neowin? Tell a friend!