« first day (129 days earlier)      last day (3516 days later) » 
01:00 - 17:0017:00 - 20:00

1:47 AM
Hey, I don't want to repost it again, but can anyone clarify on the logic behind pointers to pointers which I inquired about here: chat.stackoverflow.com/transcript/message/19135149#19135149
 
 
2 hours later…
3:30 AM
Hey guys, little stuck on a problem. I am trying to understand what this does:

if (argc == 3)
{
srand48((long int) atoi(argv[2]));
}
srand48 is 48 bits and long int is 32bits ???
 
 
2 hours later…
5:49 AM
helloc @Kamiccolo;
wrong room
@Owatch assignments in C are value only, thus the value of right hand expression (rvalue) is assigned to the memory of the left hand expression (lvalue)
ClassName *pointer2 = pointer
means: "copy the value of the right hand expression into the memory block known as pointer2".
notice that ClassName *pointer2 = pointer is different from *pointer2 = pointer, the former, * is part of the declarator for pointer2, and in the latter, * is the dereference operator
 
6:37 AM
@Wehelie I'm not familiar with those functions, but apparently the way it is designed, it expects to get seeded with a 32 bit number, even if the corresponding random function gives a 48 bit number. See publib.boulder.ibm.com/infocenter/zvm/v6r1/index.jsp?topic=/…
 
The srand48() function replaces the high order (leftmost) 32 bits of this storage with the seedval argument value and the low order 16 bits of this storage with the value 330E (base 16).
 
 
1 hour later…
8:13 AM
in Lounge<C++>, 2 mins ago, by Sirajul_Islam
and the chat group for C is not available. :(
 
Anyone here?
 
You are
 
can you help ?
as you've seen there on C++
@sehe
@sehe
you'd you please help me on this matter?
 
You're welcome to stop plinking
 
8:17 AM
You're confused about Python looping? Because that's the only question I see
 
Yes
That's a few years ago
 
Oh. Sorry to bother you then
 
:p
no, actually not. :)
 
>
I've be given some names and have to sort them alphabetically,
here the solution http://ideone.com/SWPFJT gives the perfect result.
but if i use user prompted inputs
then this: http://ideone.com/3qqmE0 gives me segfault error.
?
 
I'll be given some names
eg: America, Bangladesh, bangladesh
and have to sort them in alphabetical order.
if there's any tie, then lowercase letter goes first then the uppercase letter,
so, output should be
America, bangladesh, Bangladesh
@Kamiccolo
 
8:37 AM
@Sirajul_Islam ufff.... Your style is twisting my eyes, seriously :} Multiple exit points and this kind of stuff return ((*a < *b) ? +1 : -1); does not really help understanding the logics.
 
Just write your own version of strcmp which is case-insensitive, then call that one through qsort
int8_t gpfunc_strcmp (const uint8_t* s1, const uint8_t* s2)
{

  while ((*s1 != '\0') && (*s2 != '\0'))
  {
    if (*s1 != *s2)
    {
      break;
    }
    else
    {
      s1++;
      s2++;
    }
  }
  return (int8_t)( (int16_t)*s1 - (int16_t)*s2 );
}
^ some strcmp implementation I once wrote
 
@Sirajul_Islam and You're expecting that first word popping into comparator is shorter than second. Because You're checking for an end of a string just on the first pointer.
 
 
1 hour later…
ASR
10:05 AM
Ho @all
 
helloc @ASR;
 
ASR
how are you ?
0
Q: importing issue with mysql version to another

ASRI have got an issue with mysql import, I have taken a backup of the mysql version 5.1.32 and importing it in to mysql 5.1.73 in to my ubuntu 10.04 system.After importing I have checked all the tables and procedures,some of tables not created and procedures not imported at all. What are the option...

 
@ASR ufff... You should provide precisely, how're exporting/importing stuff. Because, as I remember, there are some flags to export triggers and procedures too, not only tables.
@ASR still in the blowin_my_freakin_head_off mood :}
 
ASR
@Kamiccolo importing is done with mysql -u root -p mycon --routines>mycon.sql
export is done with mysql -u root -p<mycon.sql
 
10:23 AM
mysqldump --routines also exports procedures.
Which is disabled by default.
 
ASR
10:36 AM
@Kamiccolo ho what to do if i want to enable ?
 
@ASR mysqldump <other mysqldump options> --routines outputfile.sql ?
just guessing.
 
Helloc all;
 
ASR
@RonniSkansing hi
 
=] Hi ASR.. still having yrouble with your sql dump / import?
 
10:55 AM
may i post my question here..it's not getting any answers..
 
ASR
@RonniSkansing yes
 
=/
@David do not know, maybe a room owner will react in abit
 
1
Q: C++ Code Injection crashes injected application

DavidI'm trying to inject a simple executable into another executable that I made, unfortunately, whenever I inject the code into the executable, it says 'simpleinjected.exe has stopped working' then it closes. I'm using CreateRemoteThread to inject the code. This is what I have done so far. Injector...

 
Asking questions here is encouraged, I think. Long as they are on topic.
 
ASR
@RonniSkansing how to degrade mysql -version in ubuntu?
 
11:01 AM
Hmm I don't think you can inject an executable in another executable. I'm far from a Windows Guru though. Usually you'd just attach a DLL to the other procedure, to get access to its memory.
 
@ASR remove the current, build the old. But you really should not do that. I know you have been struggling with this a couple of days. Have you setup a question with how/where you are stuck?
 
@Lundin i tried attaching it to firefox, it doesn't work.
 
@David Not even if you build it as dll?
 
@Lundin yes, even if i build it as a dll, it injects into custom app as dll and executes but it doesn't execute in firefox though it injects successfully
 
Ah well, I'm probably not the right person to ask about advanced Windows programming topics :)
There's some articles about dll injection on codeproject.com, iirc
 
11:12 AM
checked out the one's on codeproject, they require inline assembly which is error prone..
 
No idea if that article is up to date though. I haven't played around with stuff like this in ages.
 
gonna try it..thanks a lot..hadn't seen that article..
 
helloc @PeterVaro;
Preparing for CodeWeek? ^_^
 
helloc PeterVaro; // wb
 
11:20 AM
@Kamiccolo nice!
 
@PeterVaro this must be a must read!
 
@Kamiccolo ikr? it is a truly working model ;)
 
@PeterVaro Couldn't agree more!
btw, found two more pieces of interesting stuff:
RFC-1149 --- A Standard for the Transmission of IP Datagrams on Avian Carriers and it's real life implementation xD
CPIP --- Python based C/C++ pre-processor, reaching it's 1.0
improved version: RFC-2549 xD
and both of those are called CPIP xD
 
11:36 AM
Jesus... do people actually get that carried away with their version handling? Seems like asking for trouble.
 
11:55 AM
@Kamiccolo that one is terribly complicated..
 
@PeterVaro the task isn't trivial neither.
 
yeah.. well..
instead of patching the old macros I think it is time to create a more complex (and not complicated) macro system
and if I were the committee I would use an existing language instead of creating one
imagine this: what if you could write python scripts right inside the C code for word processing
(or any other language, it really doesn't matter)
it would be awesome, to have all the power you always wanted, not a limited, hard to hack very very static macro system..
but ofc that's a different story, and I also understand why the macros are as limited as they are
 
@PeterVaro or Lua xP But I get Your point. It's already too many different languages intended to be used for similar purposes. But isn't this a problem with most of the OpenSource? Huge decomposition. And reinventing the wheel.
 
however, I still hate the fact, that macros are dumb: FUNC(,,,) will think you passed 4 args :(
@Kamiccolo exactly
 
user3079266
helloc all;
 
12:06 PM
helloc @Mints97; // web;
 
user3079266
anything interesting happened? =)
 
not that I know of =]
 
12:24 PM
been testing pigeon driven internet xD
 
user3079266
@Kamiccolo huh? what do you mean?
 
@Mints97 Check this out xP
 
user3079266
"9 packets transmitted, 4 packets received, 55% packet loss" no thanks, I'll stick with the standard implementation... :D
 
helloc all;
 
user3079266
helloc @Apoorv;
 
12:41 PM
@Mints97 but these are real pigeons!
helloc @Apoorv;
 
user3079266
@PeterVaro so what? I see tons of these bastards here every day :D
 
> this technology suffers from poor latency
lol
 
@Mints97 I know, we have them too, "flying rats" but still -- it is nice to have a protocol for these bastards ;)
 
the advantage of the technology is that it takes the same time regardless of size of the data
unless there's a change in weight of course
 
btw this one is pure gold ;)
 
user3079266
12:52 PM
@PeterVaro that's awesome :D
 
@PeterVaro :)
 
@Lundin oldie but goldie that one is;)
@Lundin although if I were the boy, I would write:
print("I will not throw paper airplanes in class"*500)
:)
 
Pfft that won't compile.
 
12:57 PM
sure it won't, it will be interpreted, instead ;)
 
user3079266
yeah, I find that specific overload in Python quite the cool thing :D but it'd be better to do it with a line-break:
print("I will not throw paper airplanes in class\n"*500)
 
you are right, yepp
or print(*("text",)*500, sep='\n')
 
user3079266
@PeterVaro that looks more like C than Python :D can you explain what this does?
 
(but yours is way simpler -- I'm just trying to be a smarty pant ;))
@Mints97 it creates a tuple with a single object, which a string: ("text",)
 
@PeterVaro that board doesn't support python
 
1:02 PM
we now multiply it by 500 which will create a tuple with 500 "text"s in it
then we unpack it with the leading asterisk: *("text",)*500
 
user3079266
@PeterVaro what's a tuple? and what's sep, a keyword for a separator in print() ?
 
which will pass 500 strings to the print function
and last: we set the separator to "\n" so that print function will place a "\n" between each arguments
 
@Mints97 A collection of objects, something like an immutable array
 
@Mints97 a tuple is an immutable object, a container like a list (but that one is mutable)
 
user3079266
@PeterVaro oh, that's why I thought the name had a function-y sound about it :D
 
1:06 PM
def print(*args, sep=' ', end='\n', file=sys.stdout, flush=False):
    # do the printing
this is the print function's prototype in python 3+
 
void print (int n)
{
  if(n > 0)
  {
    printf("%d", "text\n");
    print(n--);
  }
}
 
user3079266
@PeterVaro got it, thanks! Doesn't Python mind not enough parameters passed to a function?
 
You just have to type print(500), look how easy it is!
 
@Lundin taking a string for the text would be better i suppose ;)
 
@Mints97 absolutely not, in python you can define default values, like in the print function => if no value is given by the named argument then it will use the default
although if you say:
def func(a, b=0):
    # func body
 
user3079266
1:10 PM
@PeterVaro oh, I got it! Silly me, I know this stuff from PHP :D
 
and you call it like: func(b=2)
then it will complain about a missing arg "a"
@Lundin nice recursion there ;)
@Apoorv LOL
 
Yeah. Who cares about how effective it is, as long as the programmer doesn't have to type or use their brain... :)
 
user3079266
@PeterVaro speaking about recursion :D we were given a task in programming class today, to implement an algorithm that would calculate the sum of the recursive set defined as S(n) = S(n-1) + 1/n^2. Having had only about 6 hours of sleep today, I misread the assignment and made a recursion to solve the problem, and got really pissed about "pointless assignments that make us do ineffective implementations" :D
 
user3079266
and it was ineffective because we had to find not the Nth term, but the first term where the difference between two terms is less than a number defined...
 
@Lundin btw: %d for char* ?
 
1:15 PM
Eh yeah it's just something I typed in chat without thinking
 
you should only write printf("text\n"); and it will be safe, since your text does not contain format specifier
 
user3079266
@PeterVaro funny thing is that it took even you about 5 mins to notice this :D
 
@Mints97 I'm coding something different -- my mind is elsewhere
 
void print (int n)
{
  extern const char* text;

  if(n > 0)
  {
    printf(text);
    print(n--);
  }
}
 
1:17 PM
there you go, prettier code has never been written
 
@Lundin and how you set text?
 
Just declare a global called text, of course!
 
user3079266
@Lundin but then you'd be unable to call the function for different text! Code reuse is important!
 
user3079266
but if you make the global mutable, it will be as bad, because they are bad in themselves :D
 
1:20 PM
const char* text;

text = "hello";
print(500);
text = "world";
print(5000);
 
user3079266
@Lundin IMHO, that isn't supposed to work...
 
Of course it is. Doesn't everyone write programs like this?
 
user3079266
but you're assigning to a const...
 
No, it is a non-constant pointer to constant data
 
I suppose it should be: print(--n);?
 
1:22 PM
Not to be confused with char* const text;
 
user3079266
@Lundin whoa! I never knew the difference! wait, but this makes it a mutable global...
 
If you couldn't tell, this was all just one big sarcasm :)
 
user3079266
@DrorK. ...and yeah, you're right. How come no one noticed? :D
 
@Lundin here is the correct version:
 
Cause I'm the only one who hates these operators :)
 
1:24 PM
static void
_print(size_t n,
       char *text)
{
    if (n > 0)
    {
        printf("%s\n", text);
        _print(--n, text);
    }
}


#define vargs(times, text, ...) times, text
#define print(...) _print(vargs(__VA_ARGS__, "example"))


int main(void)
{
    print(10);
    print(10, "hello");
    return 0;
}
 
He's been running the program and counting lines on the command prompt
 
user3079266
@Lundin don't play such jokes on me. I didn't learn C by books and I am not sure of my knowledge... ><
 
with default values ofc ;)
 
The whole purpose of recursion is for teachers to teach it in school, so that when the students later on in their life become teachers, they can teach it in school, so...
4
 
@DrorK. you are not the only one.. trust me
 
1:26 PM
@Apoorv I don't know what I hate more, these operators as arguments/array indices, or the default: --i :)
 
@Lundin and how exactly would you traverse a binary tree without recursion?
or write a nice and idiomatic Common LISP function?
 
@PeterVaro My B+ tree is without function-recursion!
 
@DrorK. it can be done -- with awful implementations
 
(tho, I've written my own recursion, so it doesn't count)
 
I've seen some before -- and to deal with graphs you really need recursion
otherwise you will do horrible and hard-toread-write-understand code
 
1:29 PM
@DrorK. probably the functions arguments and array indices even more
 
You can write binary trees completely without recursion, the code just turns kind of harder read that way.
 
@PeterVaro I think that readability is only within context
 
Binary search and various sorting algorithms are some of the few valid cases where recursion can be used
 
@DrorK. you keep saying that -- but I've told you earlier it is not that "personal preference" as you think it is
 
user3079266
@PeterVaro I know about tree implementations that house their trees all in one 1-dimensional array and work by iterating it, and work effectively - I've even written one myself, once. But it is definitely hard to read, understand and debug...
 
1:31 PM
Hmm actually, I have one such snippet here and it doesn't look all that bad....
 
@Mints97 if the tree is immutable it is a good solution
 
@Lundin Snippet of what?
 
int16_t gpfunc_binarySearch (void* const keyObject,
                           	 void* const table,
		                         uint16_t objectSize,
		                         uint16_t tableSize,
		                         ComparisonType compFunc)
{
  int16_t return_val;
  int16_t top = (int16_t)(tableSize - 1u);
  int16_t bottom = 0;
  int16_t current;
  int16_t cmp;

  return_val = -1;

  while(top >= bottom)
  {
    current = (top + bottom) / 2;

    cmp = compFunc(keyObject, (uint8_t*)table + (current*objectSize));
 
otherwise you have to keep updated that array
which is very time consuming and really not a good solution
 
a binary search, replacement for standard C bsearch
 
1:32 PM
(you already have a data structure)
 
@Lundin But that's a search, not a tree
 
Yes, but it is a good example that unrolling recursion doesn't necessarily make the code harder to read.
 
Only when you don't need "back tracking"
 
Mind you that code is MISRA-C compliant for an embedded system, so it looks a bit funny
 
Then it gets bloated
 
1:34 PM
anyway, it's time to make a nice cup o' tea ;)
 
Programmers drink coffee, you know that!
 
user3079266
@Lundin not all do :D I can't get myself used to its taste...
 
@Lundin I drink coffee too -- but right now I need tea ;)
 
What I found very irritating... that I couldn't out-perform the function-recursion with a stack
 
1:40 PM
@Mints97 I started drinking coffee when I was 20 so you have plenty of times to get used to it ;)
 
I started drinking coffee in uni when I studied programming :P
Might have been all the Java they had us study...
 
user3079266
@Lundin meh, I wish we were studying Java instead of goddamned C#
 
Meh it's the same thing :)
Visual J++
 
@Mints97 altough I'm really a novice in both languages, I think C# is way better than Java -- at least not that verbose (but has nice features too)
 
user3079266
the more I learn about the good points of this language, the stronger I hate its execution model. It could have made a brilliant alternative to Java, but it's stuck on Windows, AND it is stuck with a slow JIT compiler, AND it doesn't even work on every Windows installation.
 
user3079266
1:43 PM
if C# was portable like Java or if it would compile to proper assembly instead of CIL, I'd love it
 
the only thing bothers me, is the fact that is belongs to MS and it was really designed to work on MS systems not everywhere
I have the same feelings about Objective-C as well
@Mints97 exactly
 
user3079266
@PeterVaro yeah, and most of my groupmates are on MacOS :D
 
Objective-C is actually standardized though? It is just that nobody but Apple actually used it in commercial products.
But Apple can't dictate how the language should be
 
@Lundin I think there is a very good reason for that -- it is a terrible language with super awesome features and capabilities
 
user3079266
1:46 PM
well, these languages may be bad, but they are definitely better than, say, Pascal :D
 
there is a very good reason why they want to switch to Swift
 
user3079266
and boy I'm glad I'm not learning pascal. And I had all the chances :D
 
@PeterVaro More likely, by the time the first Macs were made, C++ was pure crap yet they wanted OO. Microsoft didn't use OO design when they made DOS/Windows.
 
I really wanted to love Go though -- but I just can't stand the whole project structure they forced on us; or the insane syntax it has at some places..
 
user3079266
@PeterVaro yeah, even I remember the hype that happened when it started: "C on steroids" they called it...
 
1:48 PM
@Mints97 You aren't a hardcore programmer before you have programmed in Turbo Pascal :P
 
@Mints97 I love the name, lots of nice ideas, like goroutines..
I wish there were perfect langauges ;)
 
user3079266
@Lundin in Russia, it's the other way around: EVERYONE learns Pascal (mostly Delphi) at school, with a few blessed exceptions to the rule like me...
 
user3079266
@PeterVaro enter Bartek with the link to the "learn Haskell" website
 
@Mints97 Haskell.. yeah.. there is a pretty good reason too, why functional languages won't be our primary languages.. they are here for like 50 years
 
@Mints97 It is a good first language really. Delphi is/was great. Makes a lot more sense to use it for learning programming than say in India, when they teach all students to program in Turbo C...
 
1:51 PM
and we are still using imperative languages, and object oriented structures and such.
 
Still I think new students should start with Java or C#, then depending on what they want to do they can learn C, C++ or web languages. C is not really a good choice for first programming language, and C++ is a god-awful choice.
 
@Lundin students should start with Python -- because in that case they focus on learning other things then the programming language itself (as it is really like plain english)
then they should learn C and C++ as those are the industry standards
and then Java and C# for enterprise usage, if they want to
oh and at the end web related stuffs
but I completely agree with you learning C as the first language is a terrible idea
 
What language is most often used for mobile phone apps? Isn't it Java or C got a renaissance?
 
user3079266
@Lundin you kidding me? learning programming? array indexes starting with one, crazy executable block and variable declaration structure, the horrendous BEGIN/END inherited from goddamn BASIC, assignment as := and comparison as =, the possibility of calling functions without parentheses at all, an "inverted" do-while that works UNTIL a statement is true... some of the many points agains Pascal/Delphi that come to my mind. I hate it.
 
@Lundin it is Java (Android) and ObjC (iOS) and JS (WebApps)
 
user3079266
1:56 PM
@Lundin I really started learning programming (if you don't count my small VB and PHP experiences) in C. And this really helped.
 
@Mints97 Then try Visual Basic and you'll love Pascal :)
 
@Mints97 if you know the basics (definitions, declarations, control flows, scopes, basic data types, the whole "programmers thinking") then C will help, a lot
you will learn how the computer is actually working
 
user3079266
@PeterVaro I didn't know ANY of this when I started learning C
 
and it is a very nice language, with a super consistent design and minimal approach
but not as a first language
 
In VB arrays start with zero, except when they start with one. Programmer decides, from file to file basis. It's a whole new dimension of stupidity you never thought possible :)
 
1:58 PM
@PeterVaro and they really start learning how to code.
 
@Mints97 I'm sure you did, you said yourself you were dealing with PHP before
@Kamiccolo exactly!
 
Starting from assembly might be also fun xP
 
@Kamiccolo for the most committed and dedicated ones ;)
(sorry for the frequent pings)
helloc @Apoorv; // wb
 
just totally different paradigm... we do have Computer Architecture on the first semester. And it was most amazing and interesting thing during whole study time. Personally, the things You can do knowing low level stuff got me hooked to programming waaay before the University.
(naaah, that's ok, full belly, can't think or work)
 
user3079266
@PeterVaro 1) in PHP, declaration = definition = first usage, change order any way you like. 2) control flows? we didn't even get to functions in the PHP class, I had to learn them myself. 3) we didn't reach variable scope back then either. 4) PHP doesn't have explicit data types.
 
2:02 PM
Everyone should just start with op codes in hex, so that the truly learn how a computer works!
 
@Mints97 I think you completely misunderstand me
 
user3079266
@PeterVaro huh?
 
aaawwww, Black Hat USA 2014 videos are out!
 
when you have no idea about programming, learning the first steps through data types like a "list" is way easier than a C like "array" -- sure, they have some similarities, but they are completely different things: one is a highly abstracted object, while the other one is a block in the memory
so what I was trying to say, if you know the basic conspets
like "we want to store things somewhere"
 
user3079266
2:04 PM
@PeterVaro PHP doesn't really have lists... :D
 
or "we want to get the stored data" or "modify the stored data:
and things like that are in the right place in your mind
then you will have a better understanding / easier time with C
because you are focusing on the other things C brings in
 
^ yea
 
like pointers, or memory allocation, or forward decalring, etc.
but if you have to learn the absolute basics while you are learning all these "extra" stuffs
I'm pretty sure you will end up with a huge mess in your head
for a very long time before you finally gets it clear what the heck is going on
 
Main problem with C is that before you can use something basic like string handling, which all newbies want in their programs, you must first learn everything about pointers and arrays.
 
@Lundin exactly => because there is no or almost no abstraction in the language
that's why it is freakin' hard to learn if you have no idea what the "high-level" goal is
 
user3079266
2:09 PM
@Lundin I sometimes miss one-operator string concatenation... :D
 
user image
3
 
:)
can't stop laughing.. this is super cute ;)
strcat should be our mascot
I mean the mascot of this room :D
 
No idea if it got some kind of copyright :)
 
I hope not -- but if I design a completely different cat for our purpose, that could work
as there is no copyright on strcat()
 
Then we should trademark it!
And let's create our own strdog , for guarding our mascot
 
2:21 PM
If strcat concaternates two strings, then obviously strdog splits one string in two.
Or maybe strdog is the name of the debugger used for chasing strcat-related bugs?
Anyways, gtg. See you later.
 
free @Lundin;
 
user3079266
free @Lundin;
 
3:56 PM
helloc all;
const char *fifo_name() {
return (CONTROL_DIR + "g13-" + boost::lexical_cast<std::string>(id)).c_str();
}
c++ wtf of the day :D
it is so easy to program C++, that code is fscking horrible and also wrong as hell :D
 
user3079266
4:17 PM
helloc @AnttiHaapala;
 
user3079266
@AnttiHaapala what exactly does this do? I must say I don't understand C++ that well...
 
4:32 PM
it is the same as ~
const char *fifo_name() {
      char *str = malloc(enough);
      sprintf(str, "%sg13-%d", CONTROL_DIR, id);
      free(str);
      return str;
}
except it is more retarded since it is C++.
 
user3079266
free(str);
return str;
wut?
 
4:47 PM
@AnttiHaapala oooof... lexical_cast remember seing it also on TC2...
 
@AnttiHaapala I have to agree with @Mints97, 1) fifo_name(void), 2) check malloc's outcome, 3) free-ing str right before returning it makes no sense...
something like this would be more appropriate:
static bool
fifo_name(char **output,
          size_t enough)
{
    #define FORMATTER "%sg13-%d"
    char *buffer = malloc(enough + sizeof FORMATTER);
    if (!buffer)
    {
        *output = NULL;
        return false;
    }
    snprintf(buffer, enough + sizeof FORMATTER, FORMATTER, CONTROL_DIR, id);
    *output = buffer;
    return true;
    #undef FORMATTER
}
 
01:00 - 17:0017:00 - 20:00

« first day (129 days earlier)      last day (3516 days later) »