-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyString.h
169 lines (125 loc) · 4.41 KB
/
myString.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#ifndef MYSTRING_H_INCLUDED
#define MYSTRING_H_INCLUDED
#include <stdio.h>
#include <stdbool.h>
/**
*@brief Gets a line from stdin.
The line length must be less than the alocated memory for the string
@param str The string where the line will be put
*/
char* myGetline(char *str);
/**
*@brief Reverses a given string
@param str The string to be reversed
*/
void myStrrev(char *str);
/**
*@brief Copies a string to another
@param destination Becomes the copy of the string from source
@param source The string to be copied
*/
void myStrcpy(char *destination, char* source);
/**
*@brief Copies a number of characters from a string to another string
@param nrCharacters Represents the number of characters to be copied
@param destination The location where the characters will be copied
@param source The string to be copied
*/
void myStrncpy(char *destination, char *source, int nrCharacters);
/**
*@brief Concatenates a string to the end of another
@param first The result of the concatenation
@param second The string to be concatenated
*/
void myStrcat(char *first, char *second);
/**
*@brief Searches for a character in string
@param str The string in which the search is made
@param characterToFind The searched character
@return A pointer to the first position in the string where the
character occurs
@return NULL if the character was not found*/
char* myStrchr(char *str, char characterToFind);
/**
*@brief Searches a string for the occurences of another string
@param first The string in which the search will be made
@param second The searched string
@return A pointer to the first occurence of second
@return NULL if the second string does not occur
*/
char* myStrstr(char *first, char *second);
/**
*@brief Computes the length of a string
@param str The string whose length will be computed
@return The length of the string*/
int myStrlen(char *str);
/**
@brief Splits the given string according to the delimiting characters
For the first time, the function is called with a pointer to a string and
a list of delimiters
For each other time, the function is called with the NULL pointer and the same list
of delimiters.
@param str The string which will be split
@param delimiters The list of delimiters
@return A pointer to a string between two occurrences of a delimiter
@return NULL if the string can be split no more
*/
char* myStrtok(char *str, char *delimiters);
/**
*@brief Transformes an English alphabet character to its uppercase version
@param character The character which will be transformed
@return The uppercase version of the character
@return The same character if the character was not alphabetical or
already uppercase
*/
char myToupper(char character);
/**
*@brief Transformes an English alphabet character to its lowercase version
@param character The character which will be transformed
@return The lowercase version of the character
@return The same character if the character was not alphabetical or
already lowercase
*/
char myTolower(char character);
/**
*@brief Transforms all the lowercase characters in the given string to
uppercase characters
@param str The transformed string
*/
void myStrupr(char *str);
/**
*@brief Transforms all the uppercase characters in the given string to
lowercase characters
@param str The transformed string
*/
void myStrlwr(char *str);
/**
*@brief Compares two strings lexicographically
@param first String to be compared
@param second String to be compared
@return A number:
@return <0 if first < second
@return 0 if first == second
@return >0 if first > second
*/
int myStrcmp(char *first, char *second );
/**
*@brief Compares a given number of characters of two string
@param first String to be compared
@param second String to be compared
@param nrCharacters Number of characters to be compared
@return A number:
\return <0 if first < second
@return 0 if first == second
@return >0 if first > second
*/
int myStrncmp(char *first, char *second, int nrCharacters);
/**
*@brief Counts the number of occurences of a given character in
a string
@param str The string in which the counting will be made
@param character The character which occurences will be counted
@return Number of occurences
*/
int myCountStringChar(char* str, char character);
#endif // MYSTRING_H_INCLUDED