std meaning c++ code example

Example 1: why to use std:: in c++

When you are using "std::" it means that you will grap the following command
from the "std" namespace.
The std namespace is an abbreviation for standard

If you use "std::" you hvae to include "#include <iostream>"

Example 2: using std c++

using namespace std;

Example 3: use of strstr in c++

/* strstr example */
#include <stdio.h>
#include <string.h>

int main ()
{
  char str[] ="This is a simple string";
  char * pch;
  pch = strstr (str,"simple");
  strncpy (pch,"sample",6);
  puts (str);
  return 0;
}

Example 4: strcmp c++

int strcmp ( const char * str1, const char * str2 );

// returning value | indicates
// <0	the first character that does not match has a lower value in ptr1 than in ptr2
// 0	the contents of both strings are equal
// >0	the first character that does not match has a greater value in ptr1 than in ptr2

Tags:

Misc Example