I am writing a C program and need to use the equivalent of the C++ substring function to return the 1st 10 characters of a string. Does C have something similar or has anyone had to write their own function?
Thanks! Got the code to compile in MSVC++ v6. It appears you are passing the program some arguments . . . is that right? If so, can you give an example?
Here's an easy one for the experience programmers (of which I am not one of). I want to perform a simple search for a string value (eg. labor) in a text line I read in between the line positions of 0 to 10. I have done multiple searches out there and have come across the Boyer-Moore search...
# include <iostream.h>
# include <string.h>
int bmsearch(char *text,char *pat,int *no,int *pos)
{
int len=strlen(pat);
int compcount=0;
int ptct=len-1;
int i,table[256];
*no=0;
for(i=0;i<256;i++)table[i]=len;
for(i=0;i<len;i++)table[pat[i]]=len-(i+1);
while(ptct<strlen(text))
{
int...
Here's a sample of the code. the line => "token = strtok(NULL, seps);" is the one that seems to cause the memory error when executing.
-----------------------------------------------------------
# include <iostream.h>
# include <string.h>
//These two include files are mandatory...
I appreciate your response to my request for help. I tried the strcpy(pat0,pos0) and the program compiles ok but I get the following memory error when running it:
"The instruction at "0x00401edb" referenced memory (I am sure you know the rest) . . ."
I believe the error is...
I am a novice C programmer and I am running into the "common" C2106 error when attempting to assign a pointer to a string like the following:
char *pos0;
char pat0[100];
. . .
pat0 = pos0;
I realize that I can't assign a memory pointer directly to a literal string. However, I need...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.