• 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

    • Towerborne, Construction Simulator, and more join Xbox Free Play Days this weekend by Pulasthi Ariyasinghe It's time for another weekend promotion from Microsoft's Free Play Days program, and this time has three games for Game Pass subscribers to jump into. Bassmaster Fishing, Construction Simulator, and Towerborne are now available to Xbox Game Pass Ultimate, Standard, and Core subscribers. As usual, any progress made during the weekend also carries over automatically if you decide to purchase a game afterward. From the trio, Towerborne is the looter brawler experience by Stoic, the studio behind The Banner Saga franchise. The title landed in early access late last year, offering players a side-scrolling action game set in a fantasy realm where you can brawl through enemies with up to three friends for upgrading your character with better gear and looks. Check out Neowin's own review of the Towerborne early access launch over here. Next arrives Construction Simulator, a popular entry in the sim space that lets you "fulfill your ambition to become a successful construction entrepreneur." You can manage the company itself, operate heavy machinery, complete a variety of building contracts, and more here. The title touts over 70 licensed construction vehicles and machines from real-world brands, two maps set in the US and Europe, as well as different types of projects. Lastly, Bassmaster Fishing offers competitive big bass fishing complete with fully licensed content. You'll be competing in the Elite Tour across 8 different real-world venues while climbing ranks and earning sponsors. There are even multiplayer modes to try out for competitive fishing. Here are the three latest Free Play Days games and their supported platforms: Bassmaster Fishing - $7.99 (Xbox Series X|S, Xbox One, PC) Construction Simulator - $19.99 (Xbox Series X|S, Xbox One, PC) Towerborne (Game Preview) - $18.74 (Xbox Series X|S, PC) This Free Play Days promotion will end on Sunday, June 15, at 11:59 pm PT. Following this, expect another round of games to enter the program next Thursday.
    • Trying to make me feel bad for taking issue with your website pushing the replacement of real authors as an opportunity to make "passive income" is a ridiculous waste of time and energy on your part. I am not criticizing you for having sponsored content on your website so you can keep the lights on. Don't project that onto me like I'm some sort of selfish monster just overreacting. The ###### software that your site is peddling will one day replace you and every other writer if you continue excusing it. Maybe you ought to get another partner that respects real human creators. Just a thought. And furthermore, your "but everybody is doing it" excuse is pathetic. There are a million other products in the world you could advertise, you never HAD to.
    • Apple CarPlay to let you stream iPhone videos to your car screen by Sagar Naresh Bhavsar In an official post for developers, Apple announced that CarPlay users will be able to watch iPhone videos on their car's display. This feature will be powered by Apple AirPlay, allowing users to stream videos wirelessly from their iPhones to their car's infotainment screen. For safety reasons, users will be able to enjoy videos on their car's display, but only when their vehicle is parked. Users won't be able to watch videos while the car is on the move. The connected iPhone will automatically detect when the car moves and will stop playing the video to avoid driver distraction. According to Apple, devs need to "integrate support for CarPlay with AirPlay video to enable this feature in your car." Carmakers will need to add support for CarPlay with AirPlay video to let users watch videos in their cars. So, this may take a while to roll out. Apple hasn't specifically mentioned whether it will be exclusive to the newly introduced and limited CarPlay Ultra, or standard CarPlay users will also be able to enjoy videos through AirPlay on their car's screen. Also, there is no clarity if existing models will get support via software update, or if it will be limited to newer models only. On the Android side, Google has also announced a bunch of new capabilities soon to be coming to Android Auto. The company has extended support for weather apps in beta for Android Auto and has confirmed that Android Auto will soon support video and browser apps as well. Image via Depositphotos
  • Recent Achievements

    • Week One Done
      fashionuae earned a badge
      Week One Done
    • One Month Later
      fashionuae earned a badge
      One Month Later
    • Week One Done
      elsafaacompany earned a badge
      Week One Done
    • Week One Done
      Yianis earned a badge
      Week One Done
    • Veteran
      Travesty went up a rank
      Veteran
  • Popular Contributors

    1. 1
      +primortal
      512
    2. 2
      ATLien_0
      265
    3. 3
      +FloatingFatMan
      195
    4. 4
      +Edouard
      174
    5. 5
      snowy owl
      125
  • Tell a friend

    Love Neowin? Tell a friend!