#### Archived

This topic is now archived and is closed to further replies.

# newbie: instr, mid, right, etc. in c?

This topic is 5828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

im just learning c...and im having trouble with string formating. is there any built in c functions that all you to do this? as you can see, i come from the VB world :D Any help or pointers will be appreciated!

##### Share on other sites
  int i = 2;char string[] = "hello";char dst[256];sprintf(dst, "This is an int %i, This is a string %s", i, string);Dst will now contain "This is an int 2 this is a string hello"

--------------------------

Those who dance are considered insane by those who cannot hear the music.

##### Share on other sites
There''s not an equivilant to instr (that im aware of), but you could
easily write a function that would be equivilant..
just break it down into parts and return the correct value, pretty simple...
same thing with right, left, mid, ect...

-eldee
;another space monkey;

thanks!

##### Share on other sites
instr in C is strstr

##### Share on other sites
Go to the bookstore. Look at the books on C.
Find one that shows how to do nearly every built-in function.
Buy the book. Look up what you want in the string section.
Have a nice day.

##### Share on other sites
quote:
Original post by Anonymous Poster
Go to the bookstore. Look at the books on C.
Find one that shows how to do nearly every built-in function.
Buy the book. Look up what you want in the string section.
Have a nice day.

im sorry...but your sarcastic remarks make you sound like an a55hole :D

##### Share on other sites
Actually, C++: The Complete Reference Third Edition does a pretty good job of it. It separates everything C from the added C++ stuff too so you''ll only get the C part if that''s what you want.

No, HTML is not an OO language.

##### Share on other sites
I was the ap a55hole. (Another reason to keep ap posting!)

And now that I've read my post, by the end
I think you can go ahead and replace the 5's with s's and
tack on another modifier if you so desire.

So what about masonium, he suggests the same thing.
Actually, my advice is better because he just tells you
importantly, you can use the book later. My advice also
will lead to a more deeper understanding as the alternative
how computers work. Sob...Sob...All I try to do is help
and this is the thanks I get??!! LOUD CRYING

Anyway, what was sarcastic about my remarks, aren't we
programmers? Aren't you?

Although I suppose my post was a bad one, you came here to
find advice because you couldn't come up with the idea to
either buy a book or look it up on an online reference and
I was too lazy to hand the functions to you and told you
to do something for yourself. Shame on me. Bad Boy! (Smack!)

I'm so glad the internet came along, my family says I've
got a big mouth and will one day get the tar beaten out of
me and they just might be right.

Certainly don't let my remarks get to ya, I've looked at your
profile and other posts you've made and you seem to be doing
some pretty nice projects.

Sound 'like' an a55hole, whatever happened to my gift?

Create.
Liv Tyler makes a really great elf.

Edited by - RolandofGilead on January 1, 2002 2:56:43 AM

##### Share on other sites
sorry...i was kinda pissed because my cousins are over my house and they are getting on my last nerve! NOW GIVE ME A HUG lol

##### Share on other sites
quote:
I was the ap a55hole. (Another reason to keep ap posting!)

Why? You''re not even man enough to use your common alias to post your thoughts? You have to hide behind further anonymity?

Grow up. If you can''t say something "face to face" (relatively speaking), you need to grow some balls kiddo.

##### Share on other sites
You''re one to talk, you''re e-mail''s not listed on your
profile. Anyway, hiding is what anonymity is for dumba.
More importantly there''s less anonymity on the net than in the
real world cause there aren''t cameras everywhere yet.
If fighting isn''t an option cause you''d lose, if running isn''t
an option cause you''d be caught, then hiding is the only other
way to remain safe.

Usually it''s just a combination of ''security'' and laziness
because I don''t keep the GD.net cookies on my computer and
have to retype my username and pw everytime I make a post.

And despite popular opinion being a ''man'' and being stupid
enough to piss off someone whom you don''t know when you
don''t know their name, what they look like, where they
live, or if they have the ability to track someone down like
a fox are not the same things. Having said that I''d like to
point out that those are my concerns whenever I go online or
outside for that matter and if no one else feels that way
then you''ve never studied history. The largest genocides
in human history have taken place during the last century.
If you''re not afraid you''re neighbors will suddenly go to
your dwelling and attack for no reason then count yourself
lucky because it happened somewhere in the world that and
every other day.

Create.
Flame me, I love the fire. I lick the flames and they
are sweet like warm chocolate dancing on my tongue.
Liv Tyler makes a really great elf.
Break our molds and shatter our compliant non-existence,
shock the world by removing us from it, if thou wish to
crack the crust the world must be moved and shaken violently
until the core screams ''I yield I yield I yield to your
power!", change the universe by making them realize they are not
the same and the glory shall be great and the price terrible
and all will be silent before a new dawn crashes and drowns
out the old, decadent, and decayed putrified ruins.

C/C++ syntax isn''t confusing. It''s just a bunch of colons,
semicolons, parentheses, brackets, letters, numbers, words,
asterisks, ampresands, carets, forward slashes, double and
single quotes, question marks, percent signs, exclamation
marks, periods, less than signs, greater than signs, equal
signs, curly braces, addition symbols, subtraction symbols,
commas, tildes, maybe some whitespace, and whatever that
symbol is called that''s used in the OR operator. (And
that''s just off the top of my head, didn''t need a book
or nothing.)

##### Share on other sites
if its not so hard, why not help somebody out?
i take it someone was a severe dick to you when you
were learning, and you feel the need to subject others
to the same kind of treatment?
"We''re all programmers" is fairly irrelevant.
since when does being a programmer mean you have to
treat newbies like shit and act like the god of syntax?

-eldee
;another space monkey;

##### Share on other sites
quote:
More importantly there''s less anonymity on the net than in the
real world cause there aren''t cameras everywhere yet.

it might just be me, but this makes no sense at all. is there a camera on my modem or something?
quote:
And despite popular opinion being a ''man'' and being stupid enough to piss off someone whom you don''t know when you
don''t know their name, what they look like, where they
live, or if they have the ability to track someone down like
a fox are not the same things... The largest genocides
in human history have taken place during the last century.
If you''re not afraid you''re neighbors will suddenly go to
your dwelling and attack for no reason then count yourself
lucky because it happened somewhere in the world that and
every other day.

where do you live? have you suffered through genecide lately?
oh, and if you actually have the skills to hunt me down based on my email address then you deserve to get your arse kicked when you show up.

--- krez (krezisback@aol.com)

##### Share on other sites
to Eldee:

comments you can see that I''m not trying to be mean
and am doing all this in a rather joking manner. More
importantly, read ELS1''s responses, he really doesn''t
seem to be pissed at me and it doesn''t appear that we''re
on bad terms and if he ever posts again I will
undoubtedly help him if I can. So lighten up.

bit of a joke with the "We''re all..." line. Programming
is sometimes logical and direct and sometimes the
programmers are too, overly so. Anyway, an exercise
frequently done in a beginning programming course is to
sometimes make a list of actions necessary to do something
considered easy, such as tying shoes. My first suggestion
was a play on that, I''m sorry I wasn''t more clear, it
would have been more clear if perhaps I did something
along the lines of

Go(&bookstore);
Look(books_on_C );
Find(book);
Look_up(info);
Have_a_ nice_day();

to ELS1:
a hug to you and a Happy New Year.

to krez:
You have given inspiration to me and with it I have come up
with a new definition for manly, "being able to kick the arse
of people who can track you down".

There might not be one on your modem, but some viruses can turn
web cameras on, and it''s possible to find every site you visit
and everyone you e-mail and everything you post on the internet.
I have not lived near or through any genocides and I thank God
for that. What I want to know is, why are you asking me? The
point I was trying to make is that the world for the majority
of the population is not a safe place to live and never has
been. As far as I know there may only be a period of 20-40
years within human history that has gone without war. Most
wars have more deaths due to disease than injuries and most
wars have seen more civilian deaths than military losses.
Crime has certainly never stopped and what bugs me is that
while violent crime see individuals put into prison, the
white collar crime, where for example many people die because
of cutting corners during construction or fire exits are
blocked and people are trapped, will only see a fine.

##### Share on other sites
quote:
There might not be one on your modem, but some viruses can turn
web cameras on, and it''s possible to find every site you visit
and everyone you e-mail and everything you post on the internet.

fair enough, but i don''t have a web cam, nor do i download virii, nor do i care if some hax0r wants to see how many times i visited gamedev.net. anyone who could do that much could probably find you when you post anon anyways. my only point was "who gives a damn?"
quote:
I have not lived near or through any genocides and I thank God for that. What I want to know is, why are you asking me? The point I was trying to make is that the world for the majority of the population is not a safe place to live and never has been.

i only asked because you mentioned the horrible genecides and how nobody should feel safe from their neighbors. i would imagine that most of the people who are in this danger you speak of aren''t avid internet posters.
quote:
As far as I know there may only be a period of 20-40
years within human history that has gone without war. Most
wars have more deaths due to disease than injuries and most
wars have seen more civilian deaths than military losses.
Crime has certainly never stopped and what bugs me is that
while violent crime see individuals put into prison, the
white collar crime, where for example many people die because
of cutting corners during construction or fire exits are
blocked and people are trapped, will only see a fine.

while i can see your point here, what does it have to do with posting anonymously? or even better yet, what does it have to do with (scrolls up to see what we''re supposed to be talking about) string functions in c++?
ok, as a fellow off-topic rambler, i''ll shut up too.

--- krez (krezisback@aol.com)

• ### Forum Statistics

• Total Topics
628732
• Total Posts
2984436

• 25
• 11
• 10
• 16
• 14