C++ :: Repeated Word Detection Program?
Mar 6, 2015
In the C++ book Programming: Principles and Practice Using C++, there's an example code like this for detecting repeated words:
Code:
#include "std_lib_facilities.h"
int main() {
int number_of_words = 0;
string previous = " "; // previous word; initialized to "not a word"
string current; // current word
while (cin >> current) // read a stream of words
[Code].....
The header file in there is sort of like a set of training-wheels for students who are complete beginners to the language; the function keep_window_open() is defined in there and it does just that on Windows systems where the output window closes too fast (in the case of the function, it's just like cin.ignore(), except it waits for you enter a character, like 'j', before it exits); programs on my Windows laptop work fine on Code::Blocks, but when I create a .exe file for them and double-click that file, it does actually close too quickly for me to be able to see the output (if it's a program like the generic "Hello World!" program that just outputs text to the screen and then exits - so all I see is the output window just flash-by really fast in those cases).
Anyway, as for the problem I'm having with the code: there are no error and compile- or link-time, but it does behave strangely at runtime, where the part inside the curly-braces of the while-loop doesn't execute at all.
View 3 Replies
ADVERTISEMENT
Sep 23, 2013
Read in n, then n lastnames, and check to see if the first in the list is ever repeated again.Here's what I have so far:
Code:
#include <stdio.h>
#include <stdlib.h>
int strcmp(char *w1, char *w2);
int main() {
int j, n;
char string1[30], string2[30];
}
[code]....
I see the problem is that it lies within n amount of string that I am not going through every string to compare to the first one.How will do compare every string to the first one?
Current output:
3
alex
alex
alex
Not repeated
3
alex
ash
peter
Not repeated
View 2 Replies
View Related
May 1, 2013
I'm trying to write a program that detects deadlock. Some of the code I already tested in an earlier stage but at this point when I run the code it somehow gets stuck. I believe that it has something to do with a negative integer value. Anyhow, the program should still work if a negative integer comes up. Here's my code so far.
Code:
#include <stdio.h>
#define FALSE 0
#define TRUE 1
int ALLOC[5][5], REQ[5][5], TOT_RES[5], process, resource, NUMB_RES=5, NUMB_PRO=5;
int TMP[5]={0}, AVAIL[5], CNTR=0, FIN[5]={FALSE}, FLAG;
}
[code]....
The program usually gets stuck after producing output displaying the "Available: " text. After that a list of tabbed numbers should appear, but it doesn't.
View 4 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
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
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
Sep 16, 2013
everything works it just how am i repeat for the next word not exiting the program.
// Word Jumble
// The classic word jumble game where the player can ask for a hint
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
enum fields {WORD, HINT, NUM_FIELDS};
[Code]...
View 1 Replies
View Related
Mar 6, 2014
How to make a program that find vowel in each word.
For ex:
he is good.
No. of vowel:
1
1
2
View 4 Replies
View Related
Feb 26, 2013
I'm trying to write a program that capitalizes every other word of a user output. (ex: if input is "i love you", the output is "i LoVe YoU").
I am using a for loop (although an if loop might be easier?) and I'm assuming that it is possible to write this program using a for loop (although I may be wrong--maybe only if loops can write this program). I have everything down EXCEPT the last step where I have to print the entire sequence. What i have so far is:
Code:
#include <cs50.h>
#include <stdio.h>
#include <string.h>
{
// get user input
printf("Type a sentence: ");
string s = GetString();
[Code] .....
The code above basically only prints out the capital letter (ex: input is "hello", output is "EL"). I don't know how to print out the entire sequence.
View 2 Replies
View Related
Oct 5, 2014
I am currently working on writing a word search program. However, I am stuck on reading the used input into the 2-D array. The code I've posted below is only dealing with the user input (I'll work on the word search part once I know i am correctly reading in the user input). I know the coding is bad practice with the use of hexadecimal, and getchar() ect. But I am currently using a microblaze microprocessor and this is just the way microblaze can interpret the information. As for the infinite while loops...that can be changed just trying to figure out how.
My question is how could I change my code to correctly read in the user input into the 2-D array?
Code:
#include "platform.h"#include "xparameters.h"
#include <stdlib.h>
#include <stdio.h>
#define MAX 20
int main() {
char grid[MAX][MAX], word[30];
int i, j, arr[2],num;
[Code] ....
View 10 Replies
View Related
May 16, 2014
take a look at this project : [URL] i want to change this project for this purpose : when a USB PRINTER is connected show a message that tell us -> hey this is a printer. which part of this project should i change and how can i separate printer devices from the others?
note: if you are using visual studio 2010 or higher and get error for this line after conversion :
#define _WIN32_WINNT 0x403
just replace all of such these lines to stdafx.cpp file. means stdafx.cpp at last should be like this :
// stdafx.cpp : source file that includes just the standard includes
// HWDetect.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#define _WIN32_WINNT 0x403
#include "stdafx.h"
View 1 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
Feb 26, 2014
Lets say I have my name "Kevin".
What would the program be so it reads "niveK"?
How to write the program for that?
View 4 Replies
View Related
Jun 5, 2013
i want to create a program (in c++ or c#) that will play mp3 files but also display a word file with the lyrics of the mp3 song playing. so if i choose a mp3 file from a list, the lyric file for that song should also be displayed. i have all the mp3 and lyric files saved on the computer so my problem is how can i link the files?
View 5 Replies
View Related
Jan 20, 2015
Still working with SDL2 and c++ my map collision is messed up since I implemented my Camera.
I do understand that everything has a relative Position on the Screen, depending on the camera.
Problem No. 1: The camera is not moving as fast as the Player, despite having the absolutly same velocity (4/-4)??? How can this be O_o
Problem No. 2: My tile collision is totally messed now. Probably its because of the difference between the Player Position and the camera :/ So if you can solve Problem no. 1, Problem number 2 might work out on its own :)
I will upload the code to github [URL] .....
View 11 Replies
View Related
Mar 21, 2015
I actually want some latest algorithms, methods or techniques which can be used in plagiarism detection software for detecting the text plagiarism offline.
View 4 Replies
View Related
Jun 23, 2013
i am having trouble finding a way to detect integers from an external text file. i currently have this code:
while(inputfile.get(wc))
{
char character = inputfile.get(wc);
if (character + 1 != NULL)
{
cout << character << endl;
}
}
this does not work as if (character + 1 != NULL) comes up with errors.
is there a way to detect ints?
View 3 Replies
View Related
May 4, 2013
I've been working on my 2D platformer for a while, and I'm running into a couple of problems. It seems to become laggy even when only about 25 entities need to do collision detection with the 8 walls in the area.
Only one thing to note: the BOOST_FOREACH(const Edge& edge, this->GetCollisonBoxEdges()) { sections actually aren't a loop, all players and enemies are basically a vertical line for purposes of hitting walls, so that's why there is some weird stuff in there (like assuming the edge is oriented a certain way, etc).
Asset::WallCollision Asset::GetClosestWallCollision(const std::vector<const Room::Wall*>& walls) const {
typedef std::pair< sf::Vector2<CoordT>, sf::Vector2<CoordT> > Edge;
const Room::Wall* wall_hit = NULL, * landing_wall = NULL;
util::intersect_ret temp, closest;
VelocityT para_vel;
if(this->m_StandingOn) para_vel = this->m_StandingOn->get_unit_parallel_vector() * this->mVelocity.x;
else para_vel = this->mVelocity;
[code].....
View 3 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
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
View Related
Mar 25, 2013
The program should find and delete all vowels in a word that is user entered. This is what I have so far and I know it should be essentially this format I just don't know how to set entered word and word equal to each other.
Code:
#include <string>
#include <iostream>
using namespace std;
void vowelremover(string&);
string word;
int main ()
{//string word;
[Code]....
View 3 Replies
View Related
Apr 2, 2012
I am trying to write a program that takes a sentence and reverses the word order.
For instance This is a Bird would become Bird a is This
Code :
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main (void) {
char input_buffer[1024];
char middle[1024];
[Code] ....
View 3 Replies
View Related
Nov 30, 2014
I don't think my processes are being created the way I want. I'm trying to create a fan of process (i.e. one parent with multiple children).
I want the parent to put together the final output image, and the children are supposed to do the edge detection on various regions of the image. Here is what I have:
Code:
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "iplib2New.c"
#define FILTER_SIZE 3
//Function prototypes
[Code] ......
View 10 Replies
View Related
Oct 14, 2014
I'm still working on my Project and the next Problem has occured: How do I detect collisions on a tilebased map? My tiles are 16x16 and the map is based on the tutorial of [URL] ..... I really like this Approach because I can define for each tile of what type it should be (so a earth tile can be walkable and lead to a secret passage).
The first Number stands for what Kind of tile it should be (e.g. Grass, Earth, Water, Blank,...) and the number after ":" stands for the type of the tile (e.g. solid, walkable, do dmg to the Player,...).
e.g.
0:0 0:0 0:0 0:0 0:0 //No tile and walkable
0:0 0:0 0:0 0:0 0:0
0:0 0:0 0:0 0:0 0:0
1:1 1:1 1:1 1:1 1:1 //Grass tile and solid
2:1 2:1 2:1 2:1 2:1 //Earth tile and solid
It's working just fine with loading the Images, but i've got no clue about the collision. I've already read a lot of stuff on the Internet but I don't get how to Combine it the structure from above. For example lazyfoo describes the collision with one object like one wall. So how can I check the Player Position with each tile?
For now there's no camera, but I plan to implement one later...
I'm trying to make a 2D platformer
View 5 Replies
View Related