473,785 Members | 2,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

strings as inputs to a function

I am trying to write a basic spell check function, one which has as
its parameters two strings arrays, one is an article from a file
source which needs to be checked for valid words, in this case the
word needs to be at least 2 characters long with no intervening
punctuation, numbers or other non-letters.
This word then needs to be lower case and then compared to the
dictionary input array. the end result being the printing out of all
the misspelled words in the article. All of this needs to be done with
few or no pointers.
Any suggestions out there?
Nov 13 '05
12 2713
On Tue, 08 Jul 2003 22:42:47 -0400, in comp.lang.c , pete
<pf*****@mindsp ring.com> wrote:
All of this needs to be done with
few or no pointers."
thats a pretty much impossible assignment, if you're using strings. I
guess you could write it all in one function, but as soon as you pass
your string to another function, *presto*, you have a pointer/
The impresion that I get, is that the input file and the dictionary
are both just supposed to be text files, not arrays of pointers.


A text file is an array of pointers to chars, written to disk with
intervening whitespace.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.c om/ms3/bchambless0/welcome_to_clc. html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 13 '05 #11
Mark McIntyre wrote:

On Tue, 08 Jul 2003 22:42:47 -0400, in comp.lang.c , pete
<pf*****@mindsp ring.com> wrote:
All of this needs to be done with
few or no pointers."
thats a pretty much impossible assignment, if you're using strings.


Why is it pretty much impossible?
I posted a solution over five hours ago.
I guess you could write it all in one function,
but as soon as you pass
your string to another function, *presto*, you have a pointer/


Between the parameters and the automatic variables,
the function has only three objects which are pointers.
I believe that satisfies the
"All of this needs to be done with few or no pointers."
specification.

Do you disaprove of my posted solution or have you not seen it?

--
pete
Nov 13 '05 #12

"pete" <pf*****@mindsp ring.com> wrote in message

Between the parameters and the automatic variables,
the function has only three objects which are pointers.
I believe that satisfies the
"All of this needs to be done with few or no pointers."
specification.
The problem is that we don't understand what your tutor is getting at. The C
language is built around pointers, and C programmers use them all the time
without thinking. Writing a C program using "few or no pointers" is a bit
like trying to write a pop song using "few or no electric guitars" - it can
be done but the result is very strange, and it seems a pointless exercise.

If your dictionary is small you can get away by passing the whole thing in
as one string and using strstr, however this isn't a natural way to approach
the problem.

You also of course need a function to extract words from your text file and
clean them up, getting rid of the punctuation.
Do you disaprove of my posted solution or have you not seen it?

I haven't tested it. The main problem is that it won't scale to a real
application.
Nov 13 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1192
by: mercuryprey | last post by:
Hi, I'm pretty new to Python, to programming overall...so how would I make something where the user inputs multiple words in a string - like "connect 123.123.123.123 21 user password" or similar, and then I can split this string up to pass these arguments to a function like ftp_connect(ip, port, user, pw) etc...? I have no idea how to "break" the string up so I can get these out of it.. thanks for answers,
5
3403
by: Dennieku | last post by:
Does anybody have an idea how to compare two strings? What I want to know is the percentage of the differences between the strings Thx, Dennieku
2
10615
by: Chris Beach | last post by:
Hi there. I'd like to be able to group together inputs on an HTML form inside, say, a <div> or <fieldset> and then use javascript to iterate through the controls in the group and disable them. Is this possible? The idea is that I can create a reusable function that will take two arguments - a checkbox object and a group object and when the checkbox is ticked, the function will disable all inputs in the group.
6
1427
by: chris | last post by:
im pretty ne to java script - so please be gentle :) basically what i want to do is construct an action in a function using a variable sent to that function ok - what i want to do is function ($number) {
7
1620
by: David Jacques | last post by:
I have to reformat a string from the form "SRID=4269;POINT(-90.673 69.4310000006199)" to GeometryFromText('POINT (-141.095 68.5430000006417)',4269) ); I have a function to do this by taking the input string as char* and returning
3
1549
by: Mars | last post by:
I don't know whether the inputs are all numbers or all strings... if they are numbers, they are sorted as numbers, if they are strings, they are sorted as strings.... e.g. input : 9 12 2 4 output : 2 4 9 12
9
2203
by: fool | last post by:
Dear group, if I want to allocate a string with a help of malloc then, shall I use the following in a loop? char *s; s = malloc(strlen(s)+1); Any pointer reference is help full. I went through the K & R book's chapter 5. But I am not able to get the answer.
2
3967
by: karafire2003 | last post by:
I've been tasked to do 2 questions. I think i got the majority of it done, but i'm having trouble. Question #1: Write a C program that accepts as input from the keyboard a floating point number, an integer, and a character. Each of these inputs should be preceded by a prompt and stored using individual variable names. Have your program call a function that assembles the input data into a single string. Display the assembled string using the...
9
2208
by: agenkin | last post by:
Are there any Python libraries implementing measurement of similarity of two strings of Latin characters? I'm writing a script to guess-merge two tables based on people's names, which are not necessarily spelled the same way in both tables (especially the given names). I would like some function that would help me make the best guess. Many thanks in advance!
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10325
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.