473,407 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Your Help Banfa

12
This is my first project, it is about arrays,libraries 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 convertStringToUpper(char* s);
 void invertString(char* s) ;
 void sortString(char* s); // alphabetically/
 void removeSpaces(char* 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(char* S); // returns 1 one if S is a palindrome, zero otherwise
 void removeStrings(char list1[][10], int* size1, const char list2[][10], int size2); // removes the words in list2 from list1;
Dec 1 '06 #1
3 1381
DeMan
1,806 1GB
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 1GB
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:
convertStringToUpper 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
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
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. ...
0
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...
192
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
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...
8
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...
6
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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,...

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.