@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet
Page: 1 2 3 4 5 6 7 8 9 10 11 12



Comments:

<0> corstan - post the code, geez
<0> and get a book
<1> rdragon, here: http://rafb.net/paste/results/DJtuBu59.html
<1> ok, I'll put those inside the func
<0> yeah, that's no good at all
<2> char* filename = blah; // Okay, because this is an initialization
<2> char* filename; filename = blah; // No go
<0> if you had a book, you might not have done this
<1> don't count on it
<2> Indeed, I'm tiring of standing in for a book.
<2> I'm cuttin him off.
<0> yeah, you're not going to keep leeching off of us corstan
<3> You can't put statements outside functions.
<1> that's fixed
<4> Run, you mean expression statements ?
<3> gribouille: I don't think the exact terminology matters in his case.



<3> Not sure if a declaration is a statement though...
<4> Run, a declaration is a statement
<3> ok
<2> You can have a statement as part of an initialization.
<2> But not otherwise.
<2> Er, expression
<3> Then the whole line is still a declaration anyway.
<2> void* foo = std::cout << "this is legal outside of function scope";
<2> std::cout << "THis isn't";
<2> Ignoring the fact that std::cout may not be fully constructed, of course.
<2> That's another bugaboo.
<1> char *filename = mystr.c_str(); doesn't work since filename is not const
<3> I doubt an ostream& will be ***igned to a void*
<2> Try it
<0> Run that's how if( stream ) is evaluated
<0> (stream is converted to void*)
<1> hm, does that mean I have to change the C code so that I have to put const in front of char *filename whereever I am using mystr.c_str() ?
<1> that's not going to be fun
<2> corstan, yes
<0> corstan - of course, since c_str (as you know) returns a const char*
<2> And I *also* told you several lines back that it should be const, anyway.
<5> I thought it was a char const* const
<0> doubtful
<1> so I have to change this function: fparse_n_nnz(filename,&n,&nnz); ?
<2> [12:20] <@Solamente> corstan, whenever a parameter that is p***ed by reference will not be modified by the function, you should make it const.
<6> jsaacmk: that doesn't make sense as a return type.
<5> constant pointer to constant character
<1> const std::string& filename in C++
<2> No, just char const*
<1> fparse_n_nnz(filename,&n,&nnz); in C
<0> unlikely jsaacmk, as the pointer is returned by value, it would be nice to ***ign it to a non-const pointer
<5> ah, I get it now
<0> (without a const_cast, especially)
<2> corstan, that doesn't help us at all.
<6> rdragon: you won't need a const_cast (if you're referring to the last const).
<2> What are the parameter types to fparse_n_nnz?
<2> The first one should be const char*
<6> s/won't/wouldn't/
<1> char *filename, int n, int nnz ....
<2> char const* filename, int n, int nnz
<0> _m_: char const* const x; ... char const* y = x; // ?
<2> You're not changing the filename that's p***ed in, are you?
<6> rdragon: sure.
<0> _m_ : yeah, I guess so
<6> rdragon: int const i = 3; int j = i;
<1> Solamente, no, planned on using the original C code without tinkering with it
<1> hm, so I am forced to change the original C code
<0> _m_ - right, my mistake
<2> The original C code should have this change, anyway
<0> corstan maybe some day you'll realize that all you need to read 2 int's from a file is ifstream x; ... int y; int z; x >> y >> z;
<1> rdragon, do you want to see the file?
<0> No.
<1> OK; I'll give it to you
<1> http://rafb.net/paste/results/eqNCLZ11.html
<1> I have functional C functions to do the parsing
<7> corstan: i see you like messing around... i suggest using readfile api and separating the numbers all by yourself.. that way it would be more fun and you would lose more time, right?
<1> all I need is some wrapper for the C++ version
<1> Deathmaster, ?
<7> nah, just ignore me
<0> corstan - and you're wasting more time in the long run trying to do that crap instead of just doing it the right way...
<1> crappy crap



<0> and it behooves me why you're trying to use C++ at all, if all you're doing is using a bunch of C stuff
<5> yay, it's like 38 degrees F out today... can go around without a jacket :)
<0> behooves was certainly the wrong word there
<1> rdragon, because I have to :)
<0> no you don't
<1> rdragon, or else I will fail miserably, more than I have
<0> you already are failing miserably
<1> rdragon, I have said that ;) ; you realize I am in school?
<1> not work or hobby
<0> this is for a cl***?
<1> yes
<0> a C++ cl***?
<1> intensive course
<1> C/C++
<0> there's no such thing as C/C++
<1> ask vawjrwrk, he is kind of amazed by it all
<0> maybe it's just your teacher that needs to be shot
<1> rdragon, temper temper
<0> you should bang on his door with all of your problems
<1> that won't work that well rdragon
<0> i can't imagine a requirement for this cl*** is to wrap all of that C stuff into C++
<1> rdragon, it's an option to save time
<1> instead of rewriting all the lines in C++
<0> but you clearly don't even know the basics of C++
<0> i wouldn't expect you to have a command over interfacing C++ with legacy code
<0> oh well, do whatever you want... i'm done
<1> Solamente, does <string> have any member functions to return non-const char array ?
<1> similar to c_str() without the const thingy
<0> no
<0> allocate a character array and copy the string into it, if you really need that
<1> that's what I am reading now: http://www.cppreference.com/cppstring/copy.html
<0> uh
<5> corstan, if you don't know why that works, you shouldn't use that code
<1> how am I going to learn without using it?
<5> use the crappy C string copy, strncpy, strcpy, or strlcpy
<0> I would use a vector<char>
<1> char *strcpy(char *s1, const char *s2);
<1> jsaacmk, thanks
<0> but of course, you will prefer using the C library
<1> rdragon, I am not using vector here
<5> but don't use that one, it's not safe
<6> std::vector<char> v(s.begin(), s.end()); // done
<1> will I die?
<5> use strlcpy if you have it, strncpy if you don't
<1> ok
<0> vector<char> is much safer and simpler
<5> I wish more computers exploded on segfaults
<1> so do I, so that coding is limited to those who can
<5> and to people who use C++
<5> the C people will have meltdowns
<0> that wouldn't seem to include you, corstan
<1> rdragon, yeye
<5> I've seen peole who are like 100x better than me at programming than me get segfaults when using C
<1> I am trying desperately to yank C with C++ here :)
<0> my programs rarely crash for a reason other than accessing a null pointer
<8> Hence the adage, everybody makes mistakes. Everybody, without exception
<7> yeeee that 128-bit to 128-bit unsigned integer division works yeeeee. thank you guys for helping me translate all that C++ code :)
<5> but I think it could have been avoided by using a vector or some other STL container
<9> hi asriel
<1> jsaacmk, why strncpy better than strcpy ?
<1> better control of number of elements copied?
<5> yes
<5> but like use strlcpy
<5> it's even better
<5> because it guarantees a '\0' at the end of the data
<6> of course, it's better, except it isn't portable.
<5> pretty much. it shouldn't be too bad to write it quick. strncpy(dest, src, length); dest[length - 1] = '\0';
<9> anyone know how to get CSplitterWnd to work?
<9> I get no errors compiling but I get a few in runtime
<1> are there seg.fault T-shirts?
<6> 'strncpy' is really a misnomer. Doesn't behave c-style stringishly in several ways.
<1> I would love to wear one now
<5> http://www.linux-onlineshop.de/product_info.php/products_id/479/product/T-Shirt_-_Segfault.html
<10> vawjrwrk: Thanks for the tip about en p***anto


Name:

Comments:

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






Return to #c++
or
Go to some related logs:

#linuxhelp
#networking
cannot find symbol testcase junit netbeans
ek pappi de
togobni
Windows Arbick
#MissKitten
#linux
#windows
#chatzone



Home  |  disclaimer  |  contact  |  submit quotes