Search:

Type: Posts; User: flexo87

Page 1 of 3 1 2 3

Search: Search took 0.00 seconds.

  1. Replies
    3
    Views
    2,763

    Thanks, I will take that into account!

    Thanks, I will take that into account!
  2. Replies
    3
    Views
    2,763

    Templates in C++

    Hi everyone,
    as the title states I have a question about templates definitions. I have defined a Stack<T> class and a BinaryTree<T> class and both work fine, in fact I can have stacks (or trees) of...
  3. If you are writing C code, then my suggestion is...

    If you are writing C code, then my suggestion is to compile using gcc. A few tips:

    -Since you have a bash shell, when you don't know how a function works, use manual (eg. type "man srand")...
  4. Replies
    15
    Views
    34,702

    You can wrap the matrix inside a struct declaring...

    You can wrap the matrix inside a struct declaring it as a char m[ROWS][COLUMNS], where ROWS and COLUMNS are macros. Then you can have a pointer to the struct and allocate it dynamically. Of course...
  5. Replies
    11
    Views
    1,893

    Yeah you're right!!... but in any case I would...

    Yeah you're right!!... but in any case I would have got warnings not compiling errors!! (if we have to be pedantic!) ;)
  6. Replies
    11
    Views
    1,893

    [flexo@localhost ~]$ gcc who.c -o who...

    [flexo@localhost ~]$ gcc who.c -o who
    [flexo@localhost ~]$ ./who
    What is your name?flexo!
    Darn glad to meet you, flexo!!
    [flexo@localhost ~]$ gcc --version
    gcc (GCC) 4.4.2 20091222 (Red Hat...
  7. Replies
    9
    Views
    1,068

    The algorithm it's fine, use another reference...

    The algorithm it's fine, use another reference which points to the Kth-node. Where K is the the value of the variable count, and use it to add the current node to the end of the list. Otherwise you...
  8. Replies
    9
    Views
    1,068

    For the first to loops it works, but after, that...

    For the first to loops it works, but after, that code assigns to the first successor of the head, the current node. That means you have a list with only two elements and each round you lost the...
  9. Replies
    15
    Views
    4,088

    If you want to work on a parameter and modify its...

    If you want to work on a parameter and modify its value, you need to work on its address. filelist is a pointer to your struct, but when you modify this value in the function (malloc), only the...
  10. Replies
    15
    Views
    4,088

    >The malloc is actually lost because you are...

    >The malloc is actually lost because you are passing it to the function. If you really need to pass it, you need a pointer to a pointer, and to pass the address of the variable, rather than passing...
  11. Replies
    15
    Views
    4,088

    Hi, if your struct is declared as a global...

    Hi, if your struct is declared as a global variable, why do you need to pass it as parameter to the function load_file_list()?... you can access to it from the functions written on the same file, so...
  12. Replies
    5
    Views
    4,471

    ..Try to put the srand() call as you wrote it, in...

    ..Try to put the srand() call as you wrote it, in the function as you don't use rand().
  13. Replies
    5
    Views
    4,471

    main_prog.c .............. int random_value;...

    main_prog.c
    ..............
    int random_value;
    .............
    srand(time(NULL)); //
    random_value= my_random(limit); // here I call my funct
    ....


    Where did you declare ant...
  14. Replies
    6
    Views
    1,910

    Use strtok(), it's not a bad idea!...Take a look...

    Use strtok(), it's not a bad idea!...Take a look at the manual.
  15. Replies
    8
    Views
    1,657

    PersonList *copyt(PersonList *allPersons) { ...

    PersonList *copyt(PersonList *allPersons) {
    int max=0,numfr=0;
    PersonList *newlist=0;

    while(allPersons)
    {
    newlist=(PersonList*) malloc(sizeof(PersonList));...
  16. Replies
    8
    Views
    1,657

    yes, why does your function not return anything?...

    yes, why does your function not return anything? in that function you can modify the list but you can't change the value of "PersonList* allPersons" which is a pointer. thus the assignment...
  17. Replies
    8
    Views
    1,657

    If you copy it you won't affect anything, but you...

    If you copy it you won't affect anything, but you have to go through the list and, copy each node, and put it into the new list. you can't just assignment newlist->next.... because you would work on...
  18. Replies
    8
    Views
    1,657

    What do you mean?.. do you want an empty list...

    What do you mean?.. do you want an empty list point to another? in that case you would assign the head of the old list to the head of the new one.
  19. Replies
    3
    Views
    60,186

    char *p=NULL; if (!p) printf("p is null"); else...

    char *p=NULL;
    if (!p) printf("p is null");
    else printf("p is not null");

    keep in mind that if i didn't write the assignment (p=NULL) its value would be undefined and the if statement wouldn't...
  20. Replies
    7
    Views
    1,040

    It is not the same, with the first (int** x) you...

    It is not the same, with the first (int** x) you are telling the compiler to not allocate memory for the array (you will do it in the program).
    with the second (int *x[10], i thnk brackets are...
  21. Thread: code output...

    by flexo87
    Replies
    6
    Views
    3,385

    >Also, & means 'address of', so unless you're...

    >Also, & means 'address of', so unless you're trying to actually display the address of something, you shouldn't be using it in printf

    s is an array of chars, so '&(s[N])' in a printf with the...
  22. Replies
    7
    Views
    1,040

    These are two kinds of declaration for an array...

    These are two kinds of declaration for an array of integers:


    int x[10]; /* allocated at compile time, each position has the size of an int */

    int *x; /* it's the same with the...
  23. Thread: What happens?

    by flexo87
    Replies
    9
    Views
    1,549

    You should also check the value that scanf...

    You should also check the value that scanf returns. It in fact tells you how many parameters have been correctly read. if you put 'x' and your scanf waits for an integer (%d) it will return 0, so if...
  24. Replies
    3
    Views
    1,287

    if it is FIFO, the oldest is the tail of the...

    if it is FIFO, the oldest is the tail of the list isn'it?



    if((pnt->next)==NULL)
    { c=head->nodecode;
    h=NULL;
    printf("%d\n",c);
    }
  25. > lines = (char **) calloc(1, sizeof(char)); ...

    > lines = (char **) calloc(1, sizeof(char));
    lines is a pointer to a pointer to a char, and you are allocating the memory for a char not for a char*.
    it should be:


    lines=(char**)calloc(1,...
Results 1 to 25 of 60
Page 1 of 3 1 2 3