Everything2
Near Matches
Ignore Exact
Full Text
Everything2

Not reading a string in C

created by ferrouslepidoptera

(idea) by ferrouslepidoptera (3.9 y) (print)   ?   (I like it!) Mon Jun 19 2000 at 3:19:30

This is a horrible C trick I use all the time for quick and dirty throwaway programs for reading in a string. It's definitely a bad way, and upon reaching EOF it behaves differently on different OSes, but still, it's handy sometimes.

{
	int x;
	char line[ 1000 ] ;

	/* this is horrible! but it's so easy. */
	x = fscanf(f, "%[^\n]%*c", line);
}

printable version
chaos

Reading a string in C A fine line between stupid and clever Why programmers don't comment their code C string
C Programming Tips and Tricks fscanf() How interactive fiction works (part 5) 'C' may be for cookie, but that's not good enough for me, dammit!
Boys Don't Cry quick and dirty C system()
string handling in C seven string guitar gets June 18, 2000
EOF Demanding crackhead grad student Obscene mnemonics Duff's device
Ernest Hemingway The Tick superpipelined strcmp
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Drink up!
24
break shot
Great Lakes
Mohawk
Blue china
Historical Evidence Regarding the Libraries of Muslim Spain
Turpentine
Confusion of language of good and evil
Temple of Jerusalem
Nathan, This Is Unacceptable
Carl Jung
I'd dance forever if they'd let me, you know
Chinese Exclusion Act of 1882
New Writeups
Heitah
Anarchy is Order(idea)
jessicaj
July 26, 2008(dream)
Berek
ABBA(person)
devolution
k-hole(place)
Nadine_2
The Sound Of Madness(review)
Twin Eclipse
Conversations with God: An Uncommon Dialogue(idea)
SwimmingMonkey
Conversations with Fo Fo- the Loneliest dog in Purgatory(fiction)
locke baron
lynx(thing)
Simulacron3
Reality, Dimensions and the Natural Ontology(essay)
SubSane
Making Love to a 9-Foot Woman(person)
Ouzo
Thoughts(idea)
antigravpussy
I fall silent, listening. The breadcrumbs are talking about us(person)
calgon
Buffalo Bill by the pool(poetry)
gate
Anarchy is Order(idea)
ushdfgakjasgh
Scribeling(thing)
E2 is a by-product of the existence of The Everything Development Company