Input :
1 <table class="mytable" name="tb" id="data"></table>
2 <table class="" name="" id=""></table>
3 <table></table>
Output:
1 Tag is = Table
Parameters are
class name : mytable
name : tb
id: data
2 Tag is = Table
Parameters are
class name : Not available
name :Not available
id: Not available
3 Tag is = Table
Parameters are
class name : Not available
name : Not available
id: Not available
1 <table class="mytable" name="tb" id="data"></table>
2 <table class="" name="" id=""></table>
3 <table></table>
Output:
1 Tag is = Table
Parameters are
class name : mytable
name : tb
id: data
2 Tag is = Table
Parameters are
class name : Not available
name :Not available
id: Not available
3 Tag is = Table
Parameters are
class name : Not available
name : Not available
id: Not available
// // A C/C++ program for splitting a string
// // using strtok()
// #include <stdio.h>
// #include <string.h>
// int main()
// {
// char str[] = "<table class="mytable" name="t_data"></table>";
// // Returns first token
// char *token = strtok(str, " ");
// // Keep printing tokens while one of the
// // delimiters present in str[].
// while (token != NULL)
// {
// printf("%s\n", token);
// token = strtok(NULL, "-");
// }
// return 0;
// }
/*#include <stdio.h>
#include <string.h>
int main ()
{
char string[50] ="Test,string1,Test,string2:Test:string3";
char *p;
printf ("String \"%s\" is split into tokens:\n",string);
p = strtok (string,",:");
while (p!= NULL)
{
printf ("%s\n",p);
p = strtok (NULL, ",:");
}
return 0;
}*/
#include <stdio.h>
#include <string.h>
int main (void) {
char str[] = "<table class=\"mytable\" name=\"t_data\" id=\"myid\" value=\"myvalue\"></table>";
char tagname[32], classname[100], name[32], id[32], value[32],nameS[32],*string;
char *p;
char *first;
string = strtok(str,"</>");
//printf ("%s\n",string);
p = strtok(string," ");
printf("Tag:%s\n", p);
p = strtok (NULL, " ");
while(p!= NULL){
printf ("%s\n",p);
p = strtok (NULL, " ");
}
// strcpy(tagname, strtok(str , "<="">"));
// strcpy(classname, strtok(NULL, " "));
// strcpy(name , strtok(NULL, " "));
// strcpy(id , strtok(NULL, " "));
// strcpy(value, strtok(NULL," "));
// strcpy(nameS,strtok(name," "));
// printf("%s\n",nameS );
// printf("tagname = %s\n", tagname);
// printf("Parameters are:\n");
// printf("class: %s\n", classname);
// printf("name: %s\n", name);
// printf("ID: %s\n", id);
// printf("Value: %s\n", value);
return 0;
}
// // using strtok()
// #include <stdio.h>
// #include <string.h>
// int main()
// {
// char str[] = "<table class="mytable" name="t_data"></table>";
// // Returns first token
// char *token = strtok(str, " ");
// // Keep printing tokens while one of the
// // delimiters present in str[].
// while (token != NULL)
// {
// printf("%s\n", token);
// token = strtok(NULL, "-");
// }
// return 0;
// }
/*#include <stdio.h>
#include <string.h>
int main ()
{
char string[50] ="Test,string1,Test,string2:Test:string3";
char *p;
printf ("String \"%s\" is split into tokens:\n",string);
p = strtok (string,",:");
while (p!= NULL)
{
printf ("%s\n",p);
p = strtok (NULL, ",:");
}
return 0;
}*/
#include <stdio.h>
#include <string.h>
int main (void) {
char str[] = "<table class=\"mytable\" name=\"t_data\" id=\"myid\" value=\"myvalue\"></table>";
char tagname[32], classname[100], name[32], id[32], value[32],nameS[32],*string;
char *p;
char *first;
string = strtok(str,"</>");
//printf ("%s\n",string);
p = strtok(string," ");
printf("Tag:%s\n", p);
p = strtok (NULL, " ");
while(p!= NULL){
printf ("%s\n",p);
p = strtok (NULL, " ");
}
// strcpy(tagname, strtok(str , "<="">"));
// strcpy(classname, strtok(NULL, " "));
// strcpy(name , strtok(NULL, " "));
// strcpy(id , strtok(NULL, " "));
// strcpy(value, strtok(NULL," "));
// strcpy(nameS,strtok(name," "));
// printf("%s\n",nameS );
// printf("tagname = %s\n", tagname);
// printf("Parameters are:\n");
// printf("class: %s\n", classname);
// printf("name: %s\n", name);
// printf("ID: %s\n", id);
// printf("Value: %s\n", value);
return 0;
}