• 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

    • PowerToys Run has already been replaced with Command Palette. Run is still functional, but it's just a matter of time before Microsoft disables it. Raycast can do much more though, and with its plugins much, much, much more...
    • Snagit 2025.2.1 by Razvan Serea Snagit is the most complete screen capture utility available. Showing someone exactly what you see on your screen is sometimes the quickest and clearest way to communicate. With Snagit, you can select anything on your screen – an area, image, article, Web page, or error message – and capture it. Then, save the screen capture to a file, send it to Snagit​'s editor to add professional effects, share it by e-mail, or drop it into PowerPoint®, Word®, or another favorite application. Capture and share images, text or video from your PC. Create beautiful presentations, flawless documentation and quickly save online content. The latest version of Snagit offers a totally new interface and workflow - making SnagIt easier for beginners to use, while still providing maximum convenience and flexibility for the screen capture experts. Snagit 2025.2.1 fixes: Fixed an issue where tags applied to images might not save correctly. Fixed a crash that might occur when closing the Editor. Download: Snagit 64-bit | 419.0 MB (Shareware) Links: SnagIt Home Page | Release Notes Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Microsoft 365 Copilot Chat now rolling out to Government Community Cloud (GCC) tenants by Paul Hill Microsoft has announced that Microsoft 365 Copilot Chat is now rolling out to Government Community Cloud (GCC) tenants. This will allow affected users to experience AI-powered chat experience in Microsoft 365 apps, while meeting US government cloud requirements. Admins will also get the tools they need to manage access, security, and compliance at scale. Since June, Microsoft has also been rolling out Web Chat access for Copilot users since early June and that’s expected to be completed by the end of the month. The rollout announced today will also bring Copilot Chat to Microsoft 365 Copilot app (web), Outlook (web and desktop), and Microsoft Teams (web and desktop). The Redmond giant said that these features are included at no additional cost with eligible Microsoft 365 and Office 365 licenses (F1, F3, G3, and G5). It also pointed out that this rollout doesn’t include AI Agent functionality; that rollout will be announced in the future. If you have used artificial intelligence chatbots like ChatGPT or Google Gemini, you’ll have probably noticed that it scours the web for up-to-date information. By default, this “web grounding” is off in GCC with Copilot Chat. If administrators want to allow it, they can explicitly enable the “Allow web search in Copilot” Cloud Policy - the exception is if the policy was already enabled in your environment, in that case your existing configuration will be followed. Microsoft says admins will also have granular controls over the AI in Microsoft 365 Copilot app, Outlook, Teams, and Web. If you’re an administrator of a GCC environment, you can check out the How to prepare section of the announcement to learn about reviewing your admin settings, educating users about how to use the AI, and monitoring the rollout. The usage of AI in government holds significant potential as shown by a recent study by the UK government. It found that AI helped to save civil servants 2 weeks, per person, per year. This time can be spent by them doing other productive activities, making government more efficient overall. With Microsoft's rollout of Copilot Chat to GCC, US government workers can be more efficient too.
    • I think that if the ad came from the AppleTV+ app, people wouldn't have been this bothered. But from the wallet app, i understand why this is frustrating. It's not anything new from Google and Microsoft, so maybe the Wallet App said to themselves, let's try it to test the water from iPhone users. Well, i hope they won't do it again. I went to see the movie yesterday in theater (in France), i hope there is a way to tell the Apple TV app to stop showing me ads for this movie now. I won't be going to see it again (maybe i'll rewatch it in a few months / years, it was nice).
    • It's on their roadmap but currently not supported.   https://kb.helpwire.app/roadmap/
  • Recent Achievements

    • Conversation Starter
      Kavin25 earned a badge
      Conversation Starter
    • One Month Later
      Leonard grant earned a badge
      One Month Later
    • Week One Done
      pcdoctorsnet earned a badge
      Week One Done
    • Rising Star
      Phillip0web went up a rank
      Rising Star
    • One Month Later
      Epaminombas earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      529
    2. 2
      ATLien_0
      205
    3. 3
      +FloatingFatMan
      168
    4. 4
      Michael Scrip
      150
    5. 5
      snowy owl
      126
  • Tell a friend

    Love Neowin? Tell a friend!