• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to secondary sidebar

GoHired

Interview Questions asked in Google, Microsoft, Amazon

Join WeekEnd Online Batch from 4-April-2020 on How to Crack Coding Interview in Just 10 Weeks : Fees just 20,000 INR

  • Home
  • Best Java Books
  • Algorithm
  • Internship
  • Certificates
  • About Us
  • Contact Us
  • Privacy Policy
  • Array
  • Stack
  • Queue
  • LinkedList
  • DP
  • Strings
  • Tree
  • Mathametical
  • Puzzles
  • Graph

strtok()

March 21, 2014 by Dhaval Dave

Function Strtok

char * strtok ( char * str, const char * delimiters );
What it does : Split string into tokens
A sequence of calls to this function split str into tokens,
which are sequences of contiguous characters separated by any of
the characters that are part of delimiters

Example

/* strtok example */


int main ()
{
  char str[] ="This-is Go,Hired Site.";
  char * pch;
  printf ("Splitting string "%s" into tokens:n",str);
  printf ("--------");
  pch = strtok (str," ,.-"); // ',' '.' and '-' will be removed
  while (pch != NULL)
  {
    printf ("%sn",pch);
    pch = strtok (NULL, " ,.-");
  }
  return 0;
}
Output:
Splitting string “This-is Go,Hired Site.” into tokens:
——–
This is Go Hired Site

Similar Articles

Filed Under: problem Tagged With: Array, string

Reader Interactions

Primary Sidebar

Join WeekEnd Online/Offline Batch from 4-April-2020 on How to Crack Coding Interview in Just 10 Weeks : Fees just 20,000 INR

Join WeekEnd Online/Offline Batch from 4-April-2020

WhatsApp us

Secondary Sidebar

Custom Search

  • How I cracked AMAZON
  • LeetCode
  • Adobe
  • Amazon
  • Facebook
  • Microsoft
  • Hacker Earth
  • CSE Interview

Top Rated Questions

Leetcode: Merge Intervals

write a c program that given a set a of n numbers and another number x determines whether or not there exist two elements in s whose sum is exactly x

Search element in a matrix with all rows and columns in sorted order

Stock Buy Sell to Maximize Profit

Reversal of LinkedList

Find shortest distances between every pair of vertices ( Dynamic Programming Floyd Warshall Algorithm)

Stickler thief

CodeChef Code SGARDEN

Password Predictor

Daughter’s Age VeryGood Puzzle

BlueStone E-commerce Interview Experience

Handle duplicates in Binary Search Tree

flattens 2 D linked list to a single sorted link list

Microsoft BING Interview Experience

Given array of 0’s and 1’s. All 0’s are coming first followed by 1’s. find the position of first 1

Given a sorted array and a number x, find the pair in array whose sum is closest to x

Templates in C++

Printing each word reverse in string

robot standing at first cell of an M*N matrix. It can move only in two directions, right and down. In how many ways, it can reach to the last cell i.e. (M, N) Code it

Level order traversal in Spiral form

Check if an array has duplicate numbers in O(n) time and O(1) space

Print Power Set of a Set

Linked List V/S Binary Search Tree

Binary Tree in Java

SAP Hiring Off-Campus General Aptitude

Serialise Deserialise N-ary Tree

Given a float number convert it into the string WITHOUT using any inbuilt Function

N teams are participating. each team plays twice with all other teams. Some of them will go to the semi final. Find Minimum and Maximum number of matches that a team has to win to qualify for finals ?

Generate next palindrome number

Find if two rectangles overlap

Copyright © 2026 · Genesis Framework · WordPress · Log in