Answer Posted / lylez00
#include <string.h>
/* strcmp */
int (strcmp)(const char *s1, const char *s2)
{
unsigned char uc1, uc2;
/* Move s1 and s2 to the first differing characters
in each string, or the ends of the strings if they
are identical. */
while (*s1 != '\0' && *s1 == *s2) {
s1++;
s2++;
}
/* Compare the characters as unsigned char and
return the difference. */
uc1 = (*(unsigned char *) s1);
uc2 = (*(unsigned char *) s2);
return ((uc1 < uc2) ? -1 : (uc1 > uc2));
}
| Is This Answer Correct ? | 7 Yes | 3 No |
Post New Answer View All Answers
Do you know about latest advancements in C++ ?
write a program that reads in a file and counts the number of lines, words, and characters. Your program should ask the user to input a filename. Open the file and report an error if the file does not exist or cannot be opened for some other reason. Then read in the contents of the file and count the number of lines, words, and characters in the file. Also print additional information about the file, such as the longest and shortest words, and longest and shortest lines. For simplicity, we define a word to be one or more characters ending with white space (a space, tab, carriage return, etc.). Functions for checking the types of characters can be found in the ctype.h header file, so you want to include this header file in your program. For example, the sentence below could be all that is in a file. This sentence IT 104 is taught in C++. has 32 characters, one line, and six words. The shortest line is 32 characters. The longest line is 32 characters. The shortest word is 2 characters. The longest word is 6 characters
What is namespace & why it is used in c++?
How would you use the functions randomize() and random()?
How do you define a class in c++?
Is it possible to write a c++ template to check for a function's existence?
Which header file allows file i/o with streams a) fileio.h b) iostream.h c) fstream.h
What is the difference between reference and pointer?
What is the difference between c++ and turbo c++?
Where must the declaration of a friend function appear?
What apps are written in c++?
Define pre-condition and post-condition to a member function in c++?
What is the error in the code below and how should it be corrected?
Write a Program for dynamically intialize a 2 dimentional array. Eg:5x20, accept strings and check for vowels and display the no.finally free the space allocated .
Which ide is best for c++?