• 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

    • I am afraid to ask but what specific crowd are you talking about? Most people wanted Mozilla to concentrate on the browser but of course are still complaining when they do that. Anyway Firefox works just fine for me. We all deserve the Chrome only future that is coming.
    • Such a missed opportunity for a company with arena sized buckets of cash. The first on device AI and they never really improved it all those years. They could have been leading this charge.
    • Glow 25.06 by Razvan Serea Glow provides detailed reporting on every hardware component in your computer, saving you valuable time typically spent searching for CPU, motherboard, RAM, graphics card, and other stats. With Glow, all the information is conveniently presented in one clean interface, allowing you to easily access and review the comprehensive hardware details of your system. Glow provides detailed information on various system aspects, including OS, motherboard, processor, memory, graphics card, storage, network, battery, drivers, and services. The well-organized format ensures easy access to the required information. You can export all the gathered data to a plain text file, facilitating sharing with others for troubleshooting purposes. No installation needed. Just decompress the archive, launch the executable, and access computer-related information. Glow runs on Windows 11 and Windows 10 64-bit versions. Glow 25.06 release notes: What's new Support provided for Windows 11 24H2 May 2025 update. Support provided for Intel Arrow Lake-H series processors. Support for AMD Ryzen AI series processors. Support for NVIDIA RTX 50 series graphics cards. Support for AMD RX 9000 series graphics cards. Support for processors and graphics cards from Intel, AMD and NVIDIA until May 2025. Support for GDDR7 graphics memory. .NET Framework June 2025 security update has been integrated. Fixed Bugs Fixed DPI bug in the Memory Test Tool that caused buttons to be nested with the table at 150% DPI and above. Fixed a translation bug in the Cache Cleanup Tool that caused an incorrect character encoding set in the Russian language. Fixed various DPI bug and character encoding bug fixes. Note: Always unzip the program before using it. Otherwise you may get an error. Download: Glow 25.06 | 2.0 MB (Open Source) View: Glow Homepage | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • How to enable the redesigned Windows 11 Start menu by Taras Buria This week, Microsoft started testing a big redesign for Windows 11's Start menu. It is now rolling out to Windows Insiders in the Dev and Beta Channels, addressing quite a few pain points in the original Start menu, which was shipped in late 2021. Nearly four years later, we finally have the long-anticipated redesign (announced earlier this year). The updated menu now features a single-page view, with all your pins and apps on one scrollable page. You can change the list of all apps between three variants: list, grid, and category. More importantly, you can now hide the recommended section in the Start menu settings (one of the most requested Start menu-related changes). The new Start menu is available in this week's Dev and Beta update. However, like always, Microsoft is rolling out changes gradually, which means you might not have the lucky ticket even on the latest build. If you do not want to wait, you can force-enable the new Start menu and its Phone Link button using a few commands in the ViVeTool app. Here is how to do that: Download ViveTool from GitHub and unpack the files in a convenient and easy-to-find folder. Run Command Prompt as Administrator and navigate to the folder containing the ViveTool files with the CD command. For example, if you have placed ViveTool in C:\Vive, type CD C:\Vive. Type vivetool /enable /id:47205210,49221331,49381526,49402389,49820095,55495322,48433719 and press Enter. Restart your computer. As usual, keep in mind that stuff in preview builds is less stable, so be aware of the risks of running preview builds. While Microsoft is not saying when the new Start menu will be available to all users, it will probably not take too long before it shows up in Release Preview and non-security updates. By the way, if you are curious, check out some of the prototypes that Microsoft considered when designing the new Start menu. Credit for the IDs goes to @phantomofearth on X.
    • reddit's "bottom of the barrel" > 99% of neowin front page "news"
  • Recent Achievements

    • Week One Done
      IAMFLUXX earned a badge
      Week One Done
    • One Month Later
      Æhund earned a badge
      One Month Later
    • One Month Later
      CoolRaoul earned a badge
      One Month Later
    • First Post
      Kurotama earned a badge
      First Post
    • Collaborator
      Carltonbar earned a badge
      Collaborator
  • Popular Contributors

    1. 1
      +primortal
      505
    2. 2
      ATLien_0
      268
    3. 3
      +FloatingFatMan
      234
    4. 4
      +Edouard
      201
    5. 5
      snowy owl
      162
  • Tell a friend

    Love Neowin? Tell a friend!