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
|
#include <stdio.h>
#include "mystr.h"
int main ()
{
char a [100], B [100], C [100], C [100];
// Function should load line of text from stdin in committed buffer
// Puts ("Enter three strings separated by ENTER");
printf ("\ n");
myreadline (a);
printf ("b: \ n");
myreadline (b);
printf ("c: \ n");
myreadline (c);
printf ("\ n");
// Function should return the length of the string
printf ("The length of the string a: %d \n", mystrlen (a));
printf ("The length of the string b: %d \n", mystrlen (b));
printf ("The length of the string c: %d \n", mystrlen (c));
// Function should copy the contents of the first entered to the second string, returns
// How many characters were copied
int n = mystrcpy (a, d);
printf ("\nSTRING is copied in d and is: %s \n", d);
printf ("copied %d characters \n", n);
// Function should be checked whether the strings are equal, returns an int
if (mystrcmp (a, b))
printf ("The strings a and b are the same! \n");
else
printf ("The strings a and b are different! \n");
// Function should check whether the first string is contained within another, returns
// Index on which the first sign of found string, or a negative number
// If not found
puts ("\n Search if any string is part of another string");
puts ("Enter the first string in which looking, and then the string you're looking for");
// Char big [] = "This is a big string in which the asking!";
// Sub char [] = "large"
char big [100], sub [100];
printf ("'main' string: \n"); myreadline (big);
printf ("'substring': \ n"); myreadline (sat);
int loc = mysubstring (big, Sat);
if (loc> = 0)
printf ("The string '%s' in the string '% s' is found on %d. place. \ n", sub, big, loc);
else
printf ("The string '% s' is not part of the string'% s' \ n ', sub, big);
char e [100], f [100], g [100];
// Load text in e and copy it to the f and g string
printf ("\ nPlease enter a text which you'll change the character: \ n");
myreadline (e);
mystrcpy (e, f);
mystrcpy (e, g);
// Function should all lower case letters in the string set to uppercase
mytoupper (e);
printf ("CAPS:%s \n", s);
// Function should be all upper-case letters set in lower case
mytolower (f);
printf ("case sensitive:% s \ n", f);
// Function should be all upper case transferred to lower case, but all in small-sized
myinvertcase (g);
printf ("inverted letter:% s \ n", g);
return 0;
}
|