Answers for "c++ strtok"

C++
0

strtok in c++

//The strtok() function in C++ returns the next token in a null terminated byte string.
#include <cstring>
#include <iostream>
using namespace std;
int main()
{
    char str[] = "parrot,owl,sparrow,pigeon,crow";
    char delim[] = ",";
    cout << "The tokens are:" << endl;
    char *token = strtok(str,delim);
    while (token)
    {
        cout << token << endl;
        token = strtok(NULL,delim);
    }
    return 0;
}
Posted by: Guest on June-05-2021
2

strcmp c++

#include<stdio.h> 
#include<string.h> 


int main() 
{  
      
    char char1[] = "coucou"; 
    char char2[] = "coucou"; 
      
  	if( strcmp(char1, char2) == 0 )
       printf("Strings are the same");
  
  	else
      prinf("Strings are differentes");
  
  
    return 0; 
}
Posted by: Guest on July-09-2020

Browse Popular Code Answers by Language