i have
#include <string.h>
but it doesn't recognize strtok()
Printable View
i have
#include <string.h>
but it doesn't recognize strtok()
post your code
Perhaps it is not implemented? Take a look into the file string.h, I guess there should be a prototype of the function.
#include <cassert.h>
#include <conio.h>
#include <cstdlib.h>
#include <iostream.h>
#include <fstream.h>
#include <string.h>
#pragma argsused
using namespace std;
int main()
{
const int MAX_RECORD = 75;
int position;
char inChar;
char quit;
string seq_line;
struct myRecord
{
char title[35];
char system[4];
double score;
};
fstream seq_in("sequential_file.txt", ios::in);
fstream rel_file("relative_file.txt", ios::in | ios::out);
for (position = 1; position <=MAX_RECORD; ++position)
{
getline(seq_in, seq_line);
strtok(position, '|');
cout << seq_line << "\n";
}
cin >> quit;
}
as I thought you are not using strtok() correctly.
The first time you call strtok to tokenise a string you pass the address of the string to be tokenised. Subsequent calls to strtok pass NULL and this tells strtok to keep tokenising the same string.
here is an example...
also your headers are wrong....Code:/* strtok()'s a string and returns a singly linked list of the tokens */
Node* Tokenise(char CopyString[],char* Delim)
{
size_t Len;
char* TokenPtr;
Node* Head=NULL;
TokenPtr=strtok(CopyString,Delim);
Len=strlen(TokenPtr)+SPACE;
Head=AddNode(Head,TokenPtr,Len);
while ((TokenPtr=strtok(NULL,Delim))!= NULL)
{
Len=strlen(TokenPtr)+SPACE;
Head=AddNode(Head,TokenPtr,Len);
}
return Head;
}
you should be using
<cassert> not <cassert.h>
<cconio> not <conio.h> be aware that this is not a standard header
<cstdlib> not <cstdlib.h>
<iostream> not <iostream.h>
<fstream> not <fstream.h>
<cstring> not <string.h>
i know those header files are wrong. i usually use the non-.h ones, but for some reason i didn't here. thanks.