Michael B Golden wrote:
>
> I was trying to work on a C program, but I can't figure out how
> to do some
> things. What I am looking for is a command in C similar to the mid$
> command in Visual Basic. What I need to do is take a string out of
> another
> string. I need to be able to specify the start point, and then end point.
Strings in C are just character arrays. So you can use something like
memcpy() if you already know the start and length.
> I also need to find a function that can look through the string, and find
> the first space (beginning where I tell it to, not the beginning), and
> return the value as an integer. Here is a sample line of input and what I
> need it to output:
>
> Input: 0 Inbox FOLD0000.FRM 443 442 1 1
> Needed Output: Inbox
I can't put your explanation and your example together in any sensible
way, but try looking at these functions:
strstr()
atoi()
> Does anyone know how to do this? I tried using the strstr() function to
> find the space, but I couldn't figure out how to work with the pointer it
> outputs.
The pointer it outputs is just another "string" (there isn't really a
string type in C). Try the following line of code to help you
understand:
printf("This is my substring: %s\n", strstr("this is my big string",
"big"));
You should get out:
This is my substring: big string
--
My public encryption key is available from
www.az.com/~drysdam/crypt/rysdam.gpg.html
and of course www.keyserver.net