• 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

    • You do realize that if you are using Full Self Driving that you aren't actually driving, right?
    • I see several on eBay. Am I blind, or is this something else? Link (I know this link isn't in UK, but an example)
    • When my Tab S9 FE tablets were upgraded to Android 15 and Samsung UI 7.0 there were some default systems changes. One of them was. when I wanted to Power Down the tablet and tapped the Power button, Gemini popped up and I had to say Power Off which then brought up the Power Off menu resulting in an extra step in powering down the tablet. After some sleuthing I found that I could turn off Gemini and go back to the old menu, so I did. Maybe one day I will be comfortable talking to a machine but that day is not today.
    • Rufus 4.8.2253 by Razvan Serea Rufus is a small utility that helps format and create bootable USB flash drives, such as USB keys/pendrives, memory sticks, etc. Despite its small size, Rufus provides everything you need! Oh, and Rufus is fast. For instance it's about twice as fast as UNetbootin, Universal USB Installer or Windows 7 USB download tool, on the creation of a Windows 7 USB installation drive from an ISO (with honorable mention to WiNToBootic for managing to keep up). It is also marginally faster on the creation of Linux bootable USBs from ISOs. A non-exhaustive list of Rufus supported ISOs is available here. It can be especially useful for cases where: you need to create USB installation media from bootable ISOs (Windows, Linux, UEFI, etc.) you need to work on a system that doesn't have an OS installed you need to flash a BIOS or other firmware from DOS you want to run a low-level utility Rufus 4.8.2253 changelog: Switch to wimlib for all WIM image processing: Greatly speeds up image analysis when opening Windows ISOs Can speed up Windows To Go drive creation (But won't do miracles if you have a crap drive) Might help with Parallels limitations on Mac (But Rufus on Parallels is still unsupported) Enables the splitting of >4GB files with Alt-E (But still WAY SLOWER than using UEFI:NTFS) Others Switch to using Visual Studio binaries everywhere, due to MinGW DLL delay-loading limitations Add more exceptions for Linux ISOs that restrict themselves to DD mode (Nobara, openSUSE, ...) Improve reporting of UEFI bootloaders in the log, with info on the Secure Boot status Fix an issue with size limitations when writing an uncompressed VHD back to the same drive Fix a crash when opening the log with the 32-bit MinGW compiled version Fix commandline parameters not being forwarded to original Windows setup.exe Download: Rufus 4.8 | Portable | ~2.0 MB (Open Source) Download: Rufus 32-bit | ARM64 Links: Rufus Home Page | Project Page @GitHub | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Recent Achievements

    • Posting Machine
      David Uzondu earned a badge
      Posting Machine
    • One Month Later
      Stokenking earned a badge
      One Month Later
    • One Month Later
      Kevin Jones earned a badge
      One Month Later
    • Week One Done
      Kevin Jones earned a badge
      Week One Done
    • One Month Later
      henryj earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      531
    2. 2
      ATLien_0
      267
    3. 3
      +Edouard
      199
    4. 4
      +FloatingFatMan
      189
    5. 5
      snowy owl
      138
  • Tell a friend

    Love Neowin? Tell a friend!