Showing posts with label String. Show all posts
Showing posts with label String. Show all posts

string.h Definitions for memory and string functions

/* string.h

Definitions for memory and string functions.

Copyright (c) Borland International 1987,1988
All Rights Reserved.
*/
#if __STDC__
#define _Cdecl
#else
#define _Cdecl cdecl
#endif

#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned size_t;
#endif

void *_Cdecl memccpy (void *dest, const void *src, int c, size_t n);
void *_Cdecl memchr (const void *s, int c, size_t n);
int _Cdecl memcmp (const void *s1, const void *s2, size_t n);
void *_Cdecl memcpy (void *dest, const void *src, size_t n);
int _Cdecl memicmp (const void *s1, const void *s2, size_t n);
void *_Cdecl memmove (void *dest, const void *src, size_t n);
void *_Cdecl memset (void *s, int c, size_t n);
void _Cdecl movedata(unsigned srcseg, unsigned srcoff, unsigned dstseg,
unsigned dstoff, size_t n);
char *_Cdecl stpcpy (char *dest, const char *src);
char *_Cdecl strcat (char *dest, const char *src);
char *_Cdecl strchr (const char *s, int c);
int _Cdecl strcmp (const char *s1, const char *s2);
char *_Cdecl strcpy (char *dest, const char *src);
size_t _Cdecl strcspn (const char *s1, const char *s2);
char *_Cdecl strdup (const char *s);
char *_Cdecl strerror(int errnum);
int _Cdecl stricmp (const char *s1, const char *s2);
size_t _Cdecl strlen (const char *s);
char *_Cdecl strlwr (char *s);
char *_Cdecl strncat (char *dest, const char *src, size_t maxlen);
int _Cdecl strncmp (const char *s1, const char *s2, size_t maxlen);
char *_Cdecl strncpy (char *dest, const char *src, size_t maxlen);
int _Cdecl strnicmp(const char *s1, const char *s2, size_t maxlen);
char *_Cdecl strnset (char *s, int ch, size_t n);
char *_Cdecl strpbrk (const char *s1, const char *s2);
char *_Cdecl strrchr (const char *s, int c);
char *_Cdecl strrev (char *s);
char *_Cdecl strset (char *s, int ch);
size_t _Cdecl strspn (const char *s1, const char *s2);
char *_Cdecl strstr (const char *s1, const char *s2);
char *_Cdecl strtok (char *s1, const char *s2);
char *_Cdecl strupr (char *s);

/* compatibility with other compilers */

#define strcmpi(s1,s2) stricmp(s1,s2)
#define strncmpi(s1,s2,n) strnicmp(s1,s2,n)

#if !__STDC__
char *_Cdecl _strerror (const char *s);
#endif


Introduction in String in C++

Variables that can store non-numerical values that are longer than one single character are known as strings.
The C++ language library provides support for strings through the standard string class. This is not a
fundamental type, but it behaves in a similar way as fundamental types do in its most basic usage.

A first difference with fundamental data types is that in order to declare and use objects (variables) of this type we
need to include an additional header file in our source code: <string> and have access to the std namespace
(which we already had in all our previous programs thanks to the using namespace statement).
// my first string
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string mystring = "This is a string";
cout << mystring;
return 0;
}
This is a string
As you may see in the previous example, strings can be initialized with any valid string literal just like numerical
type variables can be initialized to any valid numerical literal. Both initialization formats are valid with strings:
string mystring = "This is a string";
string mystring ("This is a string");
Strings can also perform all the other basic operations that fundamental data types can, like being declared without
an initial value and being assigned values during execution:
// my first string
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string mystring;
mystring = "This is the initial string content";
cout << mystring << endl;
mystring = "This is a different string content";
cout << mystring << endl;
return 0;
}
This is the initial string content
This is a different string content