| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<agentsim> from what I see it doesn't speed up queries tho... <bonk`> in vs 2005 where is the setting for loading symbols ? <traket> hi there <traket> a simple pointer ask <Soronel> traket: we can't help you until you ask a question <traket> i've got "int matrix[5][5]" and "int **p". is there anyway to make something like p=matrix ? <traket> i've tried almost everything <jamesd-> trket: no, as matrix doesn't contain any pointers. <jamesd-> traket: you could make an array of 5 pointers, to matrix[0] through matrix[4], and point p at the first element of *that*. <traket> i know, but I can do int *p=matrix[0] <traket> ok, that's what i thought. thanks a lot <jamesd-> traket: yes, matrix[0] is an array, which decays to a pointer to its first element: that's the same as int *p=&(matrix[0][0]); <rogy> is there anyway to add two strings together like math? i have a string reading a file token by token, and i need to add the numbers which are in the file... <traket> I know <jamesd-> traket: you can do int (*p)[5]=matrix if you like. Then p is a pointer to an array of 5 ints, the first element of matrix. <rogy> or how do i go about converting a string into a double? <agentsim> rogy: boost::lexical_cast<> <jamesd-> calc convert2 <CalcMe> convert2 = A nice way to convert between data types is to use a templated function to wrap around stringstreams. For Example: template<cl*** TO, cl*** FROM> TO lexical_cast(FROM blah) { TO t; std::stringstream ss; ss<<blah; ss>>t; return t; } . USE: TYPE d = lexical_cast<TYPE>(someString); *Note* this exists in boost as boost::lexical_cast in a better form (with error checking). <handle> hey <cynic> the boost version is a mess. It takes parameter by copy and throws for stream errors. bleargh <rogy> hm... <rogy> thank you, ill look into that <Cowmoo> why does it take parameter by copy? <cynic> because they thought they were coding java <jamesd-> cynic: I presume you don't know the people, or why they wrote it that way... <Cowmoo> er? <cynic> jamesd-: that's right. <Cowmoo> so does anyone know? I'm genuinely curious <pepp^> apocryphal <Cowmoo> I mean anyone in the channel <jamesd-> I have a feeling that p*** by value does allow some optimizations that can be inhibited by p***ing by const reference. But memory fails me. <rogy> do i need to include anything at the top? (sorry for dumb questions, new to this) <rogy> to use the lexical cast <jamesd-> rogy: you either define it, or include a header that does so. <Cowmoo> <boost/lexical_cast.hpp> <pepp^> At this point in the day my productivity takes a dip <Cowmoo> er, make sure you install Boost btw <cynic> you don't need to install all of boost, thanks to bcp <jamesd-> rogy: if you use the definition from the calc, you need to include <sstream>. <Cowmoo> yeah <rogy> thanks again <handle> i want to try out something new for me - want to write a CGI app in c++ - what API/lib/component should i use? <pepp^> you'll need to include everything you wish you use <pepp^> handle: what is a CGI app? <christof> i have a struct inside a cl*** how do i acces it? <jamesd-> handle: you mean the common gateway interface, rather than computer graphics stuff? <cynic> christof: with :: scope oeprator <cynic> operator <christof> aha <jamesd-> christof: the question is too vague. <handle> common gateway interface <christof> i used it like this image->image_f.f_height <jamesd-> handle: Not sure if anyone's been mad enough to publish CGI libraries for C++, as C++ is ill-suited to CGI applications. <cynic> #include <makecgiworkwithc++.h> <christof> "invalid use of 'struct sswf::TagImage::image_t" <christof> i get that error <cynic> what's image_f ? <jamesd-> christof: what's the type of image, what's the type of image_f? <christof> its the struct <cynic> is it image_t with inverse t ? <handle> hm - web server host machine can execute my executable - just need to bind it to web server through some interface, i guess <pepp^> some of the p***ages on GRE are too hard to finish them within the given time <rogy> jamesd, do you mind if i msg you? <christof> jamesd-, image_t is a struct and f_width and f_height is long <jamesd-> calc msg <CalcMe> msg = If you have a question then ask it, if you want to discuss a topic, then do it. Asking us "Can I msg you?" or sending unsolicited private msgs is unwanted; asking in the channel shares the answer with all! <christof> jamesd-, image_t is inside the created cl*** image <pepp^> jamesd-: that is right. We are nto evil. We like to share knowledge. <jamesd-> chrisof: you have not answered my question yet, which was what its type is, and that of image. <jamesd-> "it's a struct" doesn't tell me what its type is. <jamesd-> And please, look carefully, don't guess. <cynic> "it's a trap!" <christof> this struct is not type <christof> is no type <jamesd-> Help me out here someone. <jamesd-> Drop my connection or something. <pepp^> jamesd-: its untyped <cynic> I can only point and laugh <pepp^> cynic: I can't point but still laugh <cynic> struct itsa{} trap; <jamesd-> christof: what do you mean, saying it's "not type" or "no type"? That doesn't make sense to me. <rogy> ok then, i am making a program which reads a specified text file, the text files contains words and numbers, so i have it read it token by token and i am supposed to add all the numbers up and get the avg, but when i add, it adds it like this, 2.45 + 2.35 would be 2.452.35. how might i correct this? should lexical_Cast be used here <jamesd-> Don't ask me to try in Swedish though. I failed to learn Swedish. <Raphael^^> :D <christof> jamesd-, well the struct isnt a type at all its a just a collection of types <jamesd-> rogy: yes, lexical cast to convert to double, then add would be reasonable. Don't add the strings themselves. <pepp^> rogy: you clearly do not know how to add. <christof> jamesd-, the type inside is a long <rogy> your right, i clearly do not. <jamesd-> christof: um, no -- struct defines a type, always, and a type which may have members, some of them data members, which have types of their own. <rogy> can you give me an example of how i would use lexical_cast? <Soronel> cristof: a struct IS a type: struct foo { }; <Soronel> foo f; the type of f is foo <pepp^> rogy: you need to *add* instead of concatenate <agentsim> lexical_cast<double>("123.456"); <jamesd-> pepp: sadly + on strings concatenates. <cynic> jamesd-: just save the log and post it to rafb quotes, and make it look funny <christof> a yes <christof> i think i confused myself <cynic> "this guy lectured me on struct" <pepp^> Rule no 1. If you do not know what you are trying to do, you can't do it. period. <rogy> `lexical_cast' undeclared (first use this function) ---- i used #include <sstream> <pepp^> jamesd-: think about it, what would it mean to + strings? i think concatenation is the reasonable behavior on strings for "+" <Cowmoo> rogy did you look at the lexical_cast definition someone calc'ed for you earlier <rogy> yes <agentsim> rogy: you need #include <boost/lexical_cast.hpp> then use boost::lexical_cast<double>(...); <jamesd-> rogy: sstream doesn't define lexical_cast, you have to either (as we said) copy the definition from the calc, or #include <boost/lexical_cast> with boost available.; <Cowmoo> did you add that definition <jamesd-> pepp: I find it reasonable enough, though I'd also find an error pretty reasonable. <jamesd-> || or . for string concatenation also seem reasonable to me. <jamesd-> Or, sometimes, just whitespace. <jamesd-> I'm an equal opportunities concatenator. <ZorbaTHut> yeah, + isn't concatenation in all languages <jamesd-> + does confuse newbies though, sometimes. <ZorbaTHut> sometimes it's addition <jamesd-> Perl will happily add strings, implicitly converting them to numbers. <ZorbaTHut> PHP will do the same <ZorbaTHut> Python, entertainingly, won't <ZorbaTHut> it'll concatenate them <jamesd-> Python seems to me to be the closest scripting language to the spirit of C++. <pepp^> Adding strings need to be defined first? What does it mean to add strings? I would only think about concatenation <Cowmoo> oi watch it <ZorbaTHut> pepp, in a loosely typed language, there is little to no difference between "37" and 37 <Cowmoo> it's not a scripting language exclusively <ZorbaTHut> "37" + "104" = 141 is quite reasonable. <jamesd-> Cowmoo: I don't care to argue definitions of the term "scripting language". <Cowmoo> ok <pepp^> ZorbaTHut: so when you want "Text" + "4" what do you get? <Soronel> Zorba: or even "100" + 37 <X-Istence> Yeah, but in PHP at least, one can concatenate using "numbers" . "124" . "483"; <ZorbaTHut> pepp, in some languages, 4 <ZorbaTHut> "Text" is equivalent to 0. <jamesd-> X-Istence: PHP got that from Perl too. <pepp^> ZorbaTHut: That is ambigous behavior. <X-Istence> Aww, the fun. <ZorbaTHut> pepp, exactly. that's why many languages move concatenation to . <X-Istence> jamesd-: Do i care? Was only giving an example. <ZorbaTHut> just to avoid the ambiguity <Soronel> pepp: some languages try to do what you mean, not what you say :) <jamesd-> Perl has dreadful DWIM-itis. Heuristics in a parser, for ****'s sake. <X-Istence> --dwiwnwis :P Apple internal gcc compiler flag (do what i want not what i said) <pepp^> Soronel: I want all languages to do what I say. Their job is to carry out my instructions blindly. IF I dont get the answer as what I mean, then I am blind or something <ZorbaTHut> IMHO, I would actually say that having separate addition and concatenation operators is closer to "do what I say, not what I mean" <ZorbaTHut> why would + have two entirely different meanings for numbers and strings? <pepp^> ZorbaTHut: after friday, you should gladly exercise your options in your not-so-evil company. <jamesd-> OCaml makes you use different operators to add ints than to add floating point numbers. Nice and explicit (but takes some getting used to). <ZorbaTHut> I'm entirely planning to. :) <pepp^> Road to millionaire: The google way. Someone please right that book. <jeffmir`> morning (sortof) <pepp^> right=write
Return to c++ or Go to some related
logs:
c++ howto WGT634U one to many linksys rv042
fiwix
|
|