@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet
Page: 1 2



Comments:

<0> stefys`: you can use fgets then use strtol/strncpy/sscanf/whatever on the string
<1> yes, i thought at it, i still can use sscanf() somehow
<1> for example, i read 1024 bytes from stdin to variable buf
<1> then i do
<1> sscanf(buf,"something %s",buf2);
<1> but i have to make sure buf2 has allocated at least 1024bytes-strlen("something ")
<0> Not sure I get the point
<1> buf can have at most 1024 bytes
<1> first 10 bytes are filled with "something "
<0> Yeah, and I don't get the point of doing such a thing
<1> so %s can match at most 1024-10=1014 bytes
<1> well i could use strncmp() since it's at the beginning of the string
<1> but i was thinking for the general case..
<2> 10x
<2> !Op :D
<3> op pls



<3> ?
<4> C_Dreamer, are you around?
<0> idle : 4 days 0 hours 9 mins 58 secs
<4> haha
<1> hey
<1> i'm trying to write an int to a file, but i know that there might be incompatibilities if another computer uses the same file
<1> because of the endianness
<1> so i was thinking that before writing it to the file, i'd do htons() to it
<1> and when reading from the file, i do ntohs() after reading
<1> but this might still be a problem on different endiannesses right ?
<5> i suggest either using text or write it in a more explicit manner (e.g., in base 256 beginning with the most significant).
<5> not just endianness, but also size. not all platforms have the same sized int's.
<1> ah you're right
<1> so i think first byte should mean the sizeof int
<1> first byte in the file filled with sizeof int
<1> next bytes filled with the int in base 256 (starting with the most significant)
<5> sounds painful. if you can't stand using text then some other well known structuring might be useful, such as xdr.
<0> Or don't use ints and use int8/16/32/64/etc
<1> ah
<1> i didn't know there's an int8
<1> i mean, i didn't know i could specify size myself
<5> there isn't an int8, unless you make it, and that can be tricky.
<5> c99 provides the possibility of int8_t, but it isn't universally required.
<1> i just write one byte to the file
<1> byte 0 means the number 0
<1> byte 255 means the number 255
<1> an unsigned char
<1> endianness matters for one byte too ?
<5> no.
<1> oh
<5> but other representation issues may exist.
<1> like what ?
<5> though i think the odds of your program being used on 1's complement or s&m systems to be nil.
<1> :o
<1> i just wanted to practice at writing a whole structure to a file
<1> and then reading from the file into the same structure
<1> but i wanted to dinamically allocate sizes in structure
<1> so the size of the structure will not be constant
<1> and i thought that i should write an number right before it to specify it's size
<1> because i want more structures in the same file
<1> am i just doing **** ?
<5> it seems okay.
<1> ah great
<1> i think i'll use the char thing
<5> but since you use a'priori knowlege of the structure why not declare a specific number of octets as well?
<1> i don't get the question, sorry
<1> a'priori ?
<5> in advance.
<5> i.e., you've described how to describe the size of an int, but you haven't yet describe the structure overall.
<1> i am using a char** in the struct
<1> i wanted to write a small db system
<1> just for practice
<1> and i'll store column names in it
<0> Ouch
<1> but i dunno how many columns are in advance
<1> i couldn't have thought of a better exercise :)
<5> heh.
<6> I get this error: warning C4018: '<' : signed/unsigned mismatch from this code: http://rafb.net/p/EKFnMH98.html May anyone help me sovling it?
<7> strlen() returns a size_t



<7> you're comparing it with an int
<7> int is signed, size_t is not
<6> you mean...s?
<6> char s[50]
<7> no
<7> strlen()
<7> and i
<8> yup just write unsigned int instead of plain int
<7> or just use size_t
<8> btw this is not standard c, write var declarations at the start of the function
<6> I didn't write the code :p
<6> My teacher did...we are using it for a task...
<6> That includes OpenGL
<6> You have a parable, and you are going to find the intersections (x1, y1) (x2,y2) and enter them on the screen
<6> So, how would the proper code be?
<6> http://rafb.net/p/rOVa9y33.html
<6> any solutions?
<9> RockmanX: it's a lot easier if you submit code with comments in english... and variable names, etc.
<6> Hehe
<10> hey dbtid
<6> anyawy....
<6> *anyway
<9> hello cara_mia
<9> time for lunhc
<9> *lunch
<10> good apetite
<6> I kinda found out something hehe
<6> glRasterPos2f(right - 0.2, bottom + 2.0);
<6> That helps a lot;)
<6> is it some way to tell the program that it should stay there, and not move, when I zoom in/out?
<1> is there anything wrong if i use closedir(opendir("dir")) to check if "dir" exists as a directory ?
<1> by closedir()'s return value
<11> int access(char *path, int mode) -- determine accessibility of file.
<1> would that work on windows too ?
<12> hello
<11> check but i dont think so
<1> FA|R_MUT3X, works for windows too, thanks
<11> ;)
<11> try googling some times its easier than u may think
<1> i am not the kind of person that's too lazy to google
<1> just that i didn't know what to search for
<1> then i thought of it
<13> dont use access
<1> why not ?
<1> seemed to work fine for my tests
<13> CAVEATS
<13> access() is a potential security hole and should never be used.
<13> you can check just as fine with fstat
<1> ah ok thanks
<1> i'll use fstat instead
<13> or stat
<13> depending on what you need to do with the directory ;)
<1> lemme read man
<13> well
<13> you should really explain what you are trying to do
<13> if its checking wether a path exists, then access wont be a security hole
<13> but if you rely on it to check wether you app has the right to write stuff to that directory
<13> it can become one
<1> veins_, just to check whether the directory exists or not
<13> you can also use stat() it will teach you how to retrieve file attributes
<1> yes i'll use stat
<1> thank you
<11> anyone ever encountered satisfiability problem ?
<13> ?
<13> FA|R_MUT3X: explain
<0> veins_: his girlfriend encounters that all the time
<13> lol
<11> given a boolean equation find a possible solution that makes the expression true
<11> if possible
<13> FA|R_MUT3X: and ?
<11> and return the solution if exists
<13> no i mean
<13> what is the problem ?
<11> -_- an efficient method to do it


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #c
or
Go to some related logs:

redhat 9 vncserver clipboard
#AllNiteCafe
centos disable screensaver
#squid
the exorcist soundtrack remix 2006
are people in tennessee stupid as shit like fl.?
Mrs Bean
#AllNiteCafe
#linux
#c++



Home  |  disclaimer  |  contact  |  submit quotes