what does std stand for in c++ code example

Example 1: using std c++

using namespace std;

Example 2: 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 3: use of strstr in c++

#include <iostream>
#include <string.h>

using namespace std;
int main() {
   char str1[] = "Apples are red";
   char str2[] = "are";
   char *ptr;
   ptr = strstr(str1, str2);

   if(ptr)
   cout<<"Occurance of \""<< str2 <<"\" in \""<< str1 <<"\" is at position "<<ptr - str1 + 1;

   else
   cout<<"There is no occurance of \""<< str2 <<"\" in "<<str1;
   return 0;
}

Example 4: 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;
}

Tags:

Cpp Example