C :: Trying To Complete A Word Search Solver

Sep 28, 2013

Been trying for a while now to complete a physics degree first year computing task I've been assigned, which is to create a wordsearch solver to read to an array a wordsearch from a .txt file and find words in all directions (x+,x-y+ etc.).

I have a feeling the program is almost complete, but will stop looking for the word once the first character of the word has already come up. For example, if I'm searching for computer, and a c exists in an array element before it, the program will stop searching. I have included my code and the wordsearch file beneath.

Code:

#include <stdio.h>#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h> //Used for the'toupper' functio
int main()
}

[code]....

View 13 Replies


ADVERTISEMENT

C :: Word By Word Search

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

C++ :: Functions Doing A Word Search

Nov 5, 2013

I am writing a program that determines how many times a word is repeated in a file without a main function. I almost have it correct but it doesn't exit after it finds how many of the last word and it just loops.

Here is my coding

int count_the_word(string filename, string word) {
ifstream word_search;
int number_the = 0
int number_is = 0
int number_of_romeos = 0
int number_case = 0
string user_input;

[Code] ....

there is also two more lines from a different txt file i just havn't coded them yet.

the main function that is used to test it is as follows
cout << count_the_word("raj.txt", "the") << endl;
cout << count_the_word("raj.txt", "is") << endl;
cout << count_the_word("raj.txt", "Romeo") << endl;
cout << count_the_word("raj.txt", "case") << endl;

it works like its supposed to but like i earlier mentioned it outputs another number after it finds how many "case" are in the file and then it loops asking for a filename.

View 2 Replies View Related

C :: Word Search Program - Filling 2D Array

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

C++ :: Search Array Of Strings - How Many Time Word Was Used

Feb 4, 2013

The function should search the array of strings to find how many times the word 'the' was used. but its only returning a 0.

int FindThe (int The, char Paragraph[], char Pattern[]) {
for (int i(0); i < 500; i++) {
if (Paragraph[i] == Pattern[0] {

[Code] ....

View 5 Replies View Related

C :: Create Word Search By Reading In Characters From A File Into Array

Sep 30, 2013

So the plan is to create a word search by reading in characters from a file into an array. This is my code so far, nowhere near finished but have encountered a problem already:

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ROWS 20
#define COLUMNS 20
int main()
{

[Code]...

My question is to do with the section highlighted in red... I can't really see why it is not printing out my array (wordsearch), it's probably very basic but I have no C experience so am not too confident in what I'm doing.

View 1 Replies View Related

C/C++ :: Search For Word In Text File And Display Entire Row Once Found

Apr 1, 2014

i've been trying to figure out to search for a word in a text file and then display everything in the same row as the word found int ie this is whats in the file

john doe 3/21/1920 tech support review team 45,000

so user wants to find tech..and everything associated with it.

so program search for tech, when it does it then display the whole row.

john doe 3/21/1920 tech support review team 45,000

I can figure out how to search for a word, but no clue how to get it to then print out the row. This is all I can figure out to do.

ifstream FileSearch;
FileSearch.open("employee");
if(FileSearch.is_open())
{string letters;// search word would be store here
string row; ??stores entire row as string
while(1)

[Code]....

View 14 Replies View Related

C++ :: Search By Word In Text File And Print Out Whole Line On Screen

Apr 7, 2013

I have a text file where in each line is 3 words and 2 int type numbers. I'm doing search by word and I want to print out to the screen the whole line where that word was found (the words is repeated in some lines). My search looks like this:

Code:
#include<iostream>
#include<string>
#include<fstream>
#include<stdlib.h>
#include <vector>
using namespace std;
int main(){
vector <string> words;
string str, paieska;

[Code] .....

How to print line(s) where I found that word?

View 9 Replies View Related

C++ :: Anagram Solver Not Solving All Words

Dec 17, 2013

I'm working on an anagram solver, and started with words 3 characters big. But it can solve some words and not others.

std::string str = "enp";
std::string match = "";
int chk = 0;

[Code].....

With the string "enp", it knows it matches "pen". But if I use "mum", it doesn't match it with "mum".

Is there something flawed with my algroithm?

View 4 Replies View Related

C/C++ :: Maze Solver Is Not Backtracking Correctly?

Mar 15, 2014

I'm working on a homework problem where we are given a class of functions to traverse a maze and must use those functions to recursively find the end.

The problem I'm having is when the function backtracks it doesn't reset the whole path it came from.

Here is my function that I have created

void solveMaze(Maze M, int path[][MAX])
{
// << overwritten to print the maze out
cout<<M;

[Code].....

View 7 Replies View Related

C# :: Sudoku Solver Using Loops / Textboxes

Apr 28, 2014

As it is known there are nine boxes and in each box we can put numbers 1-9 without repetition. I am trying to check a given filled Sudoku puzzle whether appropriate numbers are inserted in each of the nine boxes. For the time being I don't consider row repetition and column repetition. I wrote the code using loops and condition

I used 9*9 text-boxes. The names of the textboxes is sequential like for example for the first box
txt11,txt12,txt13
txt14,txt15,txt16
txt17,txt18,txt19

Actually, I used also the controls id to access the text boxes, and each box is checking with the neighboring boxes for equality both in forward -> and backward <-

image

So here is the code

public void BoxCheck() {
int start = 82, end = 74;
int i, b, f;
for (int p = 1; p <= 9; p++, start -= 9, end -= 9) {
richTextBox1.AppendText("Box " + 1);

[Code] ....

This works pretty fine, but is is the right way to do it? it is efficient? Remember for a full checking I have to include row check and column check as well, this is just for checking within each of the 9 boxes in Sudoku.

View 6 Replies View Related

C++ :: Implementation Of Linear Programming Solver

Sep 17, 2013

I am trying to implement the linear programming solver. This is the header file of the linear programming solver :

/*!
internal
Representation of a LP constraint like:
(c1 * X1) + (c2 * X2) + ... = K
or <= K
or >= K
Where (ci, Xi) are the pairs in "variables" and K the real "constant".
*/

[Code] .....

I want to parse all the constraints and bounds as inputs and get the maximum value of the objective function as the output using the above lpsolver header file. I have also attached the sample file below.

View 14 Replies View Related

C++ :: Shortest Path Maze Solver Algorithm

Mar 26, 2014

I'm working on a maze solving program. So far I got the program to solve a maze using the recursive backtracking algorithm. I represent the maze as vector<vector<Square>> where Square is an enum that contains the kind of square (empty, wall, etc.). I use a class Point that contains 2 ints which are used for subscripting the vector of vectors. I have a Point begin and Point end. Now I want the program to solve the maze using the shortest path. I can either use the A* algorithm, Dijkstra's algorithm, or the breadth first search algorithm.

View 6 Replies View Related

C/C++ :: Quadratic Equation Solver - Simplification Function

Jul 6, 2014

So, I successfully made a program that will perform the quadratic equation on three numbers, imaginary or real. however, i am now trying to simplify the result, as to get rid of the "/2a" on the bottom. Hence the simplify() function. I just started to create the simplification function, and am attempting to divide the imaginary part of the solution as well as the real part of the solution by 2a. Somehow, it gives the error, "error:invalid operands of types 'int' and 'double *' to binary 'operator*'" on lines 105 and 106. I suspect it has to do with the pointers and references that i am passing as parameters. Also, just an aside, I have never actually seen "/=" be used. It can be, right? I know "+=" can be.

#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>//simplify the answer
using namespace std;
int count=0;
//prototyping
double ans_1(double,double,double);

[Code] ....

View 5 Replies View Related

C++ :: Convert SUDOKU Solver From Depth-First To Breadth-First

Mar 5, 2013

Code:
/* Sudoku solver using dept-first search*/

#include <iostream>
#include <stack>
using namespace std;
struct valpos//structure which carries information about the position of the cell and its value {
int val;
int row;
int col;

[Code] ....

View 3 Replies View Related

C++ :: Reading Complete Sentences From A File

Mar 3, 2013

I need to extract full sentences from a file and the save them in a set. I tried getline to get a full line and then removed the characters after the period. This method doesn't work too well if the other half of the sentence is on another line. How should i fix this?

View 8 Replies View Related

C++ :: Complete Graph Data Structure

Apr 13, 2013

I need building a complete graph from a file. The format in the file is as follows.

[ vertex 1] [ x_coordinate 1] [ y_coordinate 1] [cityname 1]
[ vertex 2] [ x_coordinate 2] [ y_coordinate 2] [cityname 2]
. . .
[ vertex n] [ x_coordinate n] [ y_coordinate n] [cityname n]

What kind of data structure shall I use in order to store date in a complete graph so there is an edge between every pair?

View 7 Replies View Related

C/C++ :: Passing Complete Array To A Function

Mar 12, 2012

I have an array defined as
double temp[5] = {0,0,0,0,0};

and a function
double function(double *something);

I am trying to do
double x = function(temp);

but this only passes the first element of the array and not the complete array to the function. How can I correct this?

View 3 Replies View Related

C# :: Sudoku Solver / Generator - Text Box Change Event

Feb 25, 2014

I am creating a sudoku solver/generator. I have 81 text boxes on the form. I want the form to automatically clean up the input, eliminating alpha characters, and values under 1 or over 10. Anyways I have this method written, but I really don't want to go through and type up a change method for each text box. Is there to write a method that fires when ANY text box is changed, and gets the string value from the changed text box?

View 5 Replies View Related

C :: Fgets Does Not Read The Complete Tab Separated Line

Sep 16, 2013

I have prepared a file through the use of following code

Code:
fprintf(file2, "%i %i %i %i %i %i
",
msg_id,
msg_size,
msg_period,
msg_deadline,
msg_producer,
msg_comsumer
);

As one can see, this file has tab separated integer entries. The file is written correctly, let us call this file "msg.txt".

I face the problem when I read this file, using fgets as follows:

Code:
char singleMessage[100];
while( fgets(singleMessage, sizeof(singleMessage), file ) )
{
puts(singleMessage);
sscanf(singleMessage, "%i %i %i %i %i %i
",
&first, &second, &third, &fourth, &fifth, &sixth);
fprintf(stderr, "first: %d, second: %d, third: %d, fourth: %d, fifth: %d, sixth: %d
",
first, second, third, fourth, fifth, sixth);
}

but fgets only retrieves until the first, i.e, if the first line in the file reads:

788004425

fgets returns only 78.

Does it have to do with how the file was written in the first place.

View 1 Replies View Related

C++ :: Program To Complete Mathematical Operations Using Matrices

Jul 10, 2014

I've been assigned to build a program which completes mathematical operations using matrices. I have to use dynamically allocated 2d arrays, and can only use * to dereference and not []. I have this code so far, but the multiply_matrix function does not work with most values. I've looked at other similar posts, which have a similar algorithm to mine, but mine does not work for some reason.

/*
*(*matrix(matrix+i)+j)
*/

#include <iostream>
//for sleep() which allows user to see messages before screen is cleared
#include <unistd.h>
using namespace std;

[Code] .....

View 1 Replies View Related

C++ :: Complete List Of Useful Function In Header File

Dec 31, 2014

i want to know about dunctions in windows.h header file.i know some of it...like

sleep()
beep()

complete list of usefull functions in said header file.

View 2 Replies View Related

C/C++ :: Merging 2 Files Program Starts But Does Not Complete

Oct 9, 2014

I'm having an issue with merging two files. Basically, my instructor gave me pseudocode and two files to merge together. Each file (a male client and a female client file) has three names and id numbers inside. The finished MergedClients.rtf should have all six clients in ascending ID order. I wrote the C++ code and after combing through a couple times to fix a few errors, it finally ran. The problem is it starts the process, but it doesn't ever finish.

I tried changing some of the bool expressions thinking I mixed up the true and false parts. After that the program ran and it created the new output file, but the file was empty. So, I don't think I mixed any of those expressions after all.

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
ifstream inFile1;
ifstream inFile2;

[code]....

View 10 Replies View Related

C/C++ :: Program That Complete Binary Number Using Recursion

Mar 12, 2015

So Im trying to make a program that completes a binary number and I have to use Recursion. Heres an example:

1] ./binary_string.out 01x0
0100
0110

2] ./binary_string.out xx
00
01
10
11

Here's what I got so far but Im stuck and I don't know what's wrong/what to do.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char* convertString(char *c,int len);
int main(int argc,char *argv[]) {
int i,length;
char *cs;

[Code] ....

View 2 Replies View Related

C++ :: Controlling Some File - Copying Complete Contents Of PDF

Aug 5, 2014

I need to open a pdf file (I used system("file_name.pdf"), and it worked). Next is that I want to copy complete content of the file (I want to execute ctrl+a). I want to give this command through my C program, then I will get the content of the windows clipboard having all the copied content.

#include <stdlib.h>
#include <stdio.h>
int main(){
/* opening a file */
system("results.pdf");

///////////////////////////////////////////////////////
/////copy the content in file (execute ctrl+a)/////
////// ------------------------------------- ////
///////////////////////////////////////////////////////

return 0;
}

View 5 Replies View Related

C++ :: Hangman Definition Game - Extract Word Randomly Form File And User Guess The Word

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







Copyrights 2005-15 www.BigResource.com, All rights reserved