473,626 Members | 3,316 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Your Help Banfa

12 New Member
This is my first project, it is about arrays,librarie s and really i don't understand how to build a library; i found this project so hard that i don't know how to begin;
can you just give any flash by how can i start my project .
Specifications:
In this project you will implement a set of functions in a set of libraries.You will implement four libraries: “myString.h”, “myMath.h”, “myCType.h” and “myLib4.h”. Each of these libraries will contain a set of functions to be described in next section. Some of the functions are original ones; others are to overwrite some well-known functions.
Functions List:

“myString.h”: (3)
 void mystrncpy(char* , const char*, int)
 void mystrcmp(const char*, const char*)
 int mystrlen(const char*)

“myMath.h”: (3)
 double myPower(double, int)
 int mycCeil(double)
 double myExp(double) // use the formula you had in a former quiz (Do Sum 200 terms)

“myCType.h” (5)
 int getAscii(char); // returns the corresponding ASCII code (Not in “ctype.h”)
 int myIsAlpha(char) ;
 int myIsDigit(char) ;
 int myIsAlnum(char) ;
 char myToUpper(char) ;

“myLib4.h”: (7)
 void convertStringTo Upper(char* s);
 void invertString(ch ar* s) ;
 void sortString(char * s); // alphabetically/
 void removeSpaces(ch ar* s);
 int stringTokenizer (char* s1, char* s2); // returns 1 if s2 is a sub-string of s2, zero otherwise ( stringTokenizer (“totofoo”, “of”) returns 1)
 int isPalindrome(ch ar* S); // returns 1 one if S is a palindrome, zero otherwise
 void removeStrings(c har list1[][10], int* size1, const char list2[][10], int size2); // removes the words in list2 from list1;
Dec 1 '06 #1
3 1393
DeMan
1,806 Top Contributor
I'm obviously not Banfa, but....

Basically,the *.h files are the definitions of the library. If they haven't been provided, you can copy the prototypes into the relevant files almost exactly how you have listed them. That is, myString.h can be listed as:
Expand|Select|Wrap|Line Numbers
  1. void mystrncpy(char* first, const char* second, int length);
  2. void mystrcmp(const char* first, const char* second);
  3. int mystrlen(const char* inputString);
  4.  
Now you can make a file myString.c which implements these methods (incidentally, I syspect mystrcmp should return something {probably an int});

mystrncpy copies the first n characters at second (or the entire string if length less than n) to first (using the variable names we used above).

mystrcmp compares two strings. Usually this type of function returns whether the strings aren't the same (that is, by convention, it returns 0 if the strings are the same, a +ve number if the first is alphabetically first and a -ve number if the second is alphabetically first). This may sound complicated, but it sort of comes naturally (ie return the difference of the last character you check)

mystrlen is a simple while loop that counnts the characters in a string until it finds the null terminator. (In c Strings are character sequences that are terminated by a null character)

in myMath.h:
myPower can be implemented using a for loop to multiply the exponent by itself.

mycCeil is a rounding function many ways to implement from casting to iterating through taking away 1 each time (and counting how many times) until you are below 0.

myExp you have solved in a previous assignment it would appear.

That's a start, more coming......
Dec 1 '06 #2
DeMan
1,806 Top Contributor
for this section, remember that a char is a 1byte integer (and in c can be treated as such)

in myCType.c
getASCII can probably be done with a cast from char to int.

myIsAlpha needs to compare whether the character is in the range of uppercase and lowercase letters (you can find an ASCII table on the net - I think Uppercase start around 65 and lowercase around 95 )

myIsDigit CAREFUL!!! - The ASCII code for digits (in the table you found for the previous function) are NOT their values, that is (and I'll try not to be confusing) the ASCII code for 1 IS NOT 1.

myIsAlnum can test one or the other from above.

myToUpper in your ASCII table you will have noticed that the uppercase characters are a fixed (-32 I think) distance from their lowercase counterparts. Test to make sure the character is a lowercase digit, then return that - 32.

myLib.c:
convertStringTo Upper iterate through your string calling myToUpper (you may need to include some files from your library)

invertString (I assume this means turn the String around) so iterate from back copying into new string

sortString if your allowed to convert all to upper do that then sort is trivial(ish), you still need to take into account special characters. If you can't do this be aware that (as far as I know) alphabetically speaking 'apple' and 'APPLE' are equal, so you may need to take into account that csorting by character values needs to take into account upper- and lowercase letters .

removeSpaces We're probably getting good atr iterating through our String by now, copy it into temp variable and copy non whitespace characters back (and remember to Null terminate)

stringTokenizer look for the first character of secondstring in first, if found compare next, if not found try further through the string. There are some traps here, but by the time you get this far you will be an expert (and by then by all means post your efforts and ask for help).

isPalindrome many ways to do this, probably the most intuitive is to have two pointers, one at the start one at the back and iterate (or recurse if you feel confident) through toward the middle while the strings are the same. You may need to only consider characters (that is... radar is obviously a palindrome, but should you recognise "Rise to vote, sir" or "Madam I'm Adam") In this case you can use the functions above to strip non alphabetic characters and spaces out of your String before starting palindrome test.

removeString compare words in list 2 and if you find them in list 1 remove them (if you get confused hear, it's might be because strings can be though of as char arrays - hence the 2 dimenional array for a list). You may like to clarify what remove means, (ie does it mean replace with null, or replace with null and move to the bottom of the array.

Hope All Goes Well & Happy Coding
Dec 1 '06 #3
thefarmer
55 New Member
well what ca i say DEMAN explain all this stuff to you, hes " DEMAN"

regards,
Dec 2 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

12
3508
by: windandwaves | last post by:
Hi Folks I have just completed a project for an accommodation finder in New Zealand - much with your help - thank you again. I would appreciate any constructive or deconstructive comments. The url is http://switch.hosts.net.nz/~admin64/index.php
0
1419
by: Vanilla Sky | last post by:
In your butt Put the boogie in your butt Put, put the boogie in your butt In your butt Put the boogie in your butt Put, put the boogie in your butt I ain't puttin no boogie in nobody's butt That's nasty, man What you talkin about
192
9445
by: Vortex Soft | last post by:
http://www.junglecreatures.com/ Try it and tell me what's happenning in the Microsoft Corporation. Notes: VB, C# are CLS compliant
0
1235
by: Gary Paris | last post by:
It seems that you have a definite problem in life. The way to solve your problem is to follow these simple steps. First take a bootable floppy in reboot your computer. At the A: Prompt, type FORMAT C: This will take care of the first problem. Second. Fill your bathtub.
8
3855
by: BugHunter | last post by:
Hello C/C++ Gurus, Could someone give me a quick hint, how to make this piece of C code Borland Builder-worthy? Or just explain the meaning of this piece of code. I try to compile a cross-plattform application named JSBSim (jsbsim.sourceforge.net) with Borland Builder 6 and the compiler came up with following syntax intepretation problem: const ENCODING * NS(XmlGetUtf8InternalEncoding)(void) { return &ns(internal_utf8_encoding).enc;...
6
1202
Niheel
by: Niheel | last post by:
I would like to honor Banfa with the Top Contributor Award. A little about Banfa: Banfa, or those of you who know him by his real name (Ben) has been a member of the community for a long time. He was part of the community when we were nothing more than a plain forum and a little content. Today he has become a moderator and a model contributor to the community. Many of us follow his lead in helping other members. Many people come to...
0
8272
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
8205
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,...
1
8370
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7206
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...
0
5579
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();...
0
4094
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4208
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1516
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.