Hello All,
Not as expected, this post is not help request
I am developing an assembler. And while I am developing this program, I found myself creating generic string functions which I ound very useful. I want to share these functions .. where should I post them?
functions I developed till now:
Code:
char ** addToString(char ** stringArray, char * string, unsigned int numberOfLines)
// which adds a string in an array of strings
Code:
char * readLine(FILE * stream)
// which returns a line from a file
Code:
char * readLine(FILE * stream, unsigned int lineNum)
// which returns the line requested by its number. Note: this function needs the function above.
// returns a string entered by the user. It's like Console.ReadLine() in C# or raw_input() in Python.
Code:
char * append(char * mainString, char * appendedString)
// appends a string to another string.
all functions above automatically handles the memory. That is, all you have to worry about is the name of the variable you create and nothing more
examples:
Code:
char * input = getstring();
// input will hold the input string from the user
Code:
char * line = readLine(filePointer);
// line will hold a line read from the file. if EOF reached, "EOF" is returned.
Code:
char * newString = append("the", " new");
// newString will hold the string "the new"