C++ :: Simple Word Counter - Show Repetition Of Word
Apr 25, 2012
I've taken part the text into 1 word per line, but I can't figure out how to printf every word only once and then add (%d) in the end to show how many repetitions of that word there are.
Code:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
int main(){
char *oneword;
[Code] ....
View 3 Replies
ADVERTISEMENT
Jun 18, 2013
I am trying to make a program which reads a text file, separates the strings into words, then finally saving and counting each different word.
When I comment out the code where it is supposed to search for the same word in the table, the program doesn't work.Am I doing something wrong with strcmp or the loop? The 'break' just exits out of that 'for' loop right?
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define WORD_MAX 500
#define LIST_MAX 500
int main(){
int i, j, find;
[Code]...
View 6 Replies
View Related
Nov 4, 2013
I am currently working on an assignment.
#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
char letter;
int count = 0;
double ppl = 0;
double finalCost = ppl * (count - 1);
[Code] ....
I am trying to create a word counter program that asks for the price per letter and then asks for the sentence they are writing. The app should then calculate the number of letters and give the total cost similar to:
You have 40 letters at $3.45 per letter, and your total is $138.00.
Everything compiles fine but when I run it the inputs don't work and it outputs:
You have -1 per letter, and your total cost is $-0.
View 2 Replies
View Related
Sep 13, 2013
I've been trying to do a RegEx, but I just can't seem to find the solution for it.
Do the following to find Test:
Test55: Will be allowed
TestABC: Will NOT be allowed
Basically, if Test is followed immediately by anything else other than a case-insensitive letter (not [a-zA-Z]), then it will pass.
View 3 Replies
View Related
Jun 25, 2014
Basically I have a text file called words. I'm supposed to extract a word randomly form the file and have the user guess the word. If they guess the word correctly in x number of tries they will receive the definition.
I'm having trouble receiving that random word and I'm getting the definitions from the file.
Here's my code:
#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
[Code] ....
This is what is in the words.txt file
apple#the usually round, red or yellow, edible fruit of a small tree
boat#a vessel for transport by water
horse#a solid-hoofed plant-eating domesticated mammal with a flowing mane and tail, used for riding
television#a system for transmitting visual images and sound that are reproduced on screens
soup#a liquid dish, typically made by boiling meat, fish, or vegetables, etc.
bottle#a container, typically made of glass or plastic and with a narrow neck
barber#a person who cuts hair
toast#sliced bread browned on both sides by exposure to radiant heat
radar#a system for detecting the presence, direction, distance, and speed of aircraft, ships, and other objects
red#of a color at the end of the spectrum next to orange and opposite violet
View 3 Replies
View Related
Feb 18, 2013
I am building a linked list and i need to display function i have. The display function displays all the letters of the word entered instead of the word itself. below is my struct, one of my functions and the display function.
Code:
//-----------struct ------------//
struct Node
{
char data;
struct Node *next;
}*Head;
[code]....
View 1 Replies
View Related
Oct 24, 2013
I'm learning programming, and C++. I've got a question, but I couldn't solve my problem so far. I need to use arrays and only basic stuff to solve this:
Create a program that reads a word from the user and then print (cout) this word on contrary. It's simple, I know, but I can't do it,. I've tried some stuff but I don't get how I will get the proper values to do this. All I know is that I can use variable.lenght().
View 7 Replies
View Related
Mar 20, 2013
I have a problem to open word document into turbo c++. i don't know how to open if the documents are in word format.
View 1 Replies
View Related
Dec 27, 2013
I want a program to display as follows..
if i enter mohandas karamchand gandhi i want output as M K Gandhi.....
i want the c++ code for this program..my error is i am not able to erase the letters of first 2 words..ie my output is Mohandas Karamchand Gandhi..
View 2 Replies
View Related
Dec 20, 2013
I have text (string) and I want to find a given word (it's ok!) and then insert another given word after the first word. The original string is beeing copied into a new string. But something is going wrong!!! Where is my mistake?
(I have some patches...)
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//insert "new_word" after each occurence of "word"
int main(){
char A[100]="In the sentence words the and the.";
[Code]...
View 8 Replies
View Related
Aug 6, 2013
int countTextWords(ifstream * file)
{
string textWord;
int wordCount = 0;
while((*file) >> textWord)
{
wordCount++;
}
return wordCount;
}
for some reason, (*file) >> textWord will not read words into the string. What am I doing wrong?
View 9 Replies
View Related
Oct 16, 2013
I have to create a list of words and then when one is repeated the program has to show with a message.
Code:
#include <vcl.h>
#include <iostream.h>
#include <conio.h>
#include <string.h>
#pragma hdrstop
[Code] ....
View 1 Replies
View Related
Aug 14, 2014
ow to read word by word from a line in file into struct. Say for example:
12345 Joe Lim KH879.00
12233 Kay Suet Yee35.98
to
struct master {
unsigned short int IDnum;
char name[30];
float salesCustomer;
};
View 1 Replies
View Related
Apr 25, 2013
i'm making a program for basic data entry.i have also included search feature which uses strcmpi() function.if i have a file name'report on tigers' and someone searched for 'tigers' then that person will not find the required file.any way i can overcome that ?
View 2 Replies
View Related
May 9, 2013
The best I could come up with is this.
while(true){
wisdomCnt++;
_stprintf_s(szBuffer, _T("%i"), wisdomCnt/10000);
TextOut(hdc,120,10,szBuffer, _tcslen(space));
}
but the program is constantly loading and clicking anywhere causes it to stop responding. Is there a better way to do this especially in Win32 API?
View 6 Replies
View Related
Mar 16, 2013
im trying to capitalize every other word. for examples input: hello output: HeLlO
View 5 Replies
View Related
Mar 1, 2015
So this is my homework: a user will enter a line of text, echo the input one word per line and capitalize each word(do not use toupper) and also needs word count and punctuation marks count. I know how to echo one word per line. How to capitalize each word without toupper? and how to do word count?
View 3 Replies
View Related
Nov 18, 2013
I would like to know how I can know if a word is before another in a string. Here's my current code.
#include <iostream>
#include <math.h>
#include <string>
#include <cstdlib>
#include <sstream>
#include <vector>
#include <iterator>
using namespace std;
int main() {
string equation;
getline (cin, equation);
[Code] .....
View 9 Replies
View Related
Nov 29, 2014
Would you use regex? (not sure how though)
Or, would you go through the hard way, and iterate through every word, until you discarded (n-1) words and reached the nth word?
The second wouldn't be so short and clear to one who reads the code, therefore i was wondering if there's a neater way.
View 1 Replies
View Related
Mar 7, 2013
I was wondering if there is a way for me to break up a word compare it one character at a time and change it according to a real word like if you have cat and dog it would go from cat to bat, bat to bag, bag to bog, then bog to dog.
View 1 Replies
View Related
Jan 28, 2015
Let's say i have some text in char array Code: char text[] = "Hello my friend"; How can i get a seperate words from it? It should be like
Code:
char a[] = "Hello";
char b[] = "my";
char c[] = "friend";
Is it possible to do?
View 2 Replies
View Related
Mar 2, 2013
Any way to do it...its only works with the first letter. So i have a txt file with information such as de3 dn5 dn7 dw9 ds1 and how to get the letters and then the number.
example:
if de print this is de; and print the number that follow de
Code:
#include <stdlib.h>
int main ()
{
FILE * pFile;
int c;
pFile=fopen ("de3.txt","r");
if (pFile==NULL) perror ("Error opening file");
else
[Code]...
View 5 Replies
View Related
Feb 26, 2013
Code:
#include <stdio.h>
int main(void)
{
int c;
int inspace;
[Code]....
I tried this code w/o no "inspace" in it and code still worked but if I made more than one blanks between words it happened vertically double newlines etc.. so I just wanna know how this "inspace" makes newline w/o blank line for each word. Is that a flag ?
View 7 Replies
View Related
Apr 12, 2013
1. Create a variable named index and nitialize it to zero(0)
2. Prompt for and input a string value from thekeyboard. Store the string inthe string variable newstring[80].
3. While (newstring[index] does not equal ‘ ’).
i. Display the character at newstring[index] followed by a NL
ii. Increment index ====================================== ...
And this is what i have done so far and i dont know where I am wrong ...
Code:
#include<stdio.h>
int main()
{
int index = 0; //initialize index to zero since first elementin an array is numbered zero
char newstring[80];
[Code] ....
View 3 Replies
View Related
Nov 15, 2014
I'm trying to write function that finds wheter the searched word exists or not. The compiler gives warning. Where is my wrong ?
|21|warning: passing argument 1 of 'strcmp' makes pointer from integer without a cast [enabled by default]|
Code:
#include <stdio.h>
#include <string.h>
int main ()
{
int result;
char arr[]="sakir emmim evde mi evde mi dedik lan";
int size=sizeof(arr)/sizeof(char);
char key[20];
scanf("%s", &key);
[Code]...
View 6 Replies
View Related
Aug 19, 2013
I am learning C programming from K & R text . i dont understand the wordcounting programing . How is working ?
Code:
#include<stdio.h>
#define IN 1
#define OUT 0
main()
[Code].....
View 6 Replies
View Related