Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
char *instring = "last.first.middle";
char *last, *first, *middle;
last = strtok ( instring, "." );
first = strtok ( NULL, "." );
middle = strtok ( NULL, "." );
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
main ()
{
char *instring = "last.first.middle";
char *last, *first, *middle;
last = strtok ( instring, "." );
first = strtok ( NULL, "." );
middle = strtok ( NULL, "." );
printf ( "Middle = %s\nLast = %s\nFirst = %s\n", middle, last, first );
}
char array [3][25];
void separate_string (char *string, char c)
{
int length = strlen (string);
int x, y = 0;
int z = 0;
char buff1 [25];
for (x = 0; x < length; x++)
{
if (string [x + 1] == NULL)
{
buff1 [z] = string [x];
buff1 [z + 1] = NULL;
if (strlen (buff1))
strcpy (array [y], buff1);
}
else if (string [x] != c)
{
buff1 [z] = string [x];
z++;
if (string [x + 1] == c)
{
buff1 [z] = NULL;
z = 0;
if (strlen (buff1))
{
strcpy (array [y], buff1);
y++;
}
}
}
}
}
printf ("\s", array [0]);
printf ("\s", array [1]);
printf ("\s", array [2]);
#include <stdio.h>
int main(void)
{
const char line[] = "last name.first name.middle name";
char last[32], first[20], middle[12];
if(sscanf(line, "%31[^.].%19[^.].%11[^.]", last, first, middle) == 3)
{
printf("first = \"%s\"\n", first);
printf("middle = \"%s\"\n", middle);
printf("last = \"%s\"\n", last);
}
return 0;
}
/* my output
first = "first name"
middle = "middle name"
last = "last name"
*/