Search:

Type: Posts; User: Salem

Page 1 of 20 1 2 3 4

Search: Search took 0.29 seconds; generated 2 minute(s) ago.

  1. Replies
    1
    Views
    58

    Eclipse is just an IDE. It doesn't come with a...

    Eclipse is just an IDE.
    It doesn't come with a compiler, hence the "g++ not found in PATH" messages.

    If you want an all-in-one complete package, try code::blocks.
    Binary releases - Code::Blocks...
  2. A couple of basic things first before trying more...

    A couple of basic things first before trying more advanced things.

    > fgets(hraci[id_hraca].meno,50,stdin);
    Don't lie about your buffer sizes.

    Use sizeof on the array you're reading into, like...
  3. You could make a union out of it. typedef...

    You could make a union out of it.


    typedef struct
    {
    uint8_t type;
    uint8_t num;
    uint8_t id;
    union {
    int value;
  4. I suppose the first question would be,...

    I suppose the first question would be, whereabouts in the world are you geographically located (country/state or equivalent).

    Second question, how far are are you willing to relocate?

    > I'm a...
  5. Replies
    5
    Views
    141

    Your concatenate is fine, so long as your array...

    Your concatenate is fine, so long as your array has a NULL sentinel value at the end.

    No sentinel, then you need to provide a count of how many elements there are.
  6. Replies
    5
    Views
    141

    As far as the compiler is concerned, a string...

    As far as the compiler is concerned, a string constant is represented as an anonymous char array.

    So your first post is


    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>

    const...
  7. Replies
    5
    Views
    141

    It's not comparing strings, it's comparing...

    It's not comparing strings, it's comparing pointers.

    And it relies on the compiler combining identical strings, so that the pointer to "" in the array is the same pointer to "" in the while...
  8. Replies
    4
    Views
    177

    > char **result = malloc(sizeof(char)); This...

    > char **result = malloc(sizeof(char));
    This doesn't allocate anywhere near enough space.
    At the very least, you need to start with


    char **result = malloc(sizeof(char*));


    Additionally,...
  9. Replies
    4
    Views
    163

    p no longer points to the start of your array. ...

    p no longer points to the start of your array.

    So you print the tail end of the array, then whatever 'garbage' there is in memory.
  10. Replies
    3
    Views
    164

    Did you look up what strcmp returns, or did you...

    Did you look up what strcmp returns, or did you just guess that it returns "true" when the strings are equal?
  11. Thread: Username change

    by Salem
    Replies
    1
    Views
    203

    Send a PM to...

    Send a PM to https://cboard.cprogramming.com/member.php?u=1
  12. Thread: smallest coin

    by Salem
    Replies
    2
    Views
    212

    Also here -> coin smallest - C++ Forum...

    Also here -> coin smallest - C++ Forum
  13. Replies
    4
    Views
    252

    > if(fscanf(fd, "%s:%[^:]:%s:%d:%d:%d:%d:%d",...

    > if(fscanf(fd, "%s:%[^:]:%s:%d:%d:%d:%d:%d", flag, nom, s, &st1, &st2, &st3, &po, &ti) != 8)
    Maybe try == 8 instead.

    In fact, this is better.


    char buff[BUFSIZ];
    while (...
  14. Replies
    17
    Views
    483

    > But I fail to see why pointer arithmetic and...

    > But I fail to see why pointer arithmetic and indirection, plus pos-increment are "obfuscation".
    For the OP, I'm pretty damn sure that what you posted would count as obfuscated.

    As for all the...
  15. Replies
    17
    Views
    483

    Any decent compiler will do that optimisation for...

    Any decent compiler will do that optimisation for you, without making the code obscure in the process.
  16. Replies
    17
    Views
    483

    > a[b] = a[b]+2; Compare with a[b] =...

    > a[b] = a[b]+2;

    Compare with
    a[b] = a[b-1]+2;

    And you want to do <10 for both loops.
  17. Something wrong with your setup if you're not...

    Something wrong with your setup if you're not getting any errors.


    $ gcc -Wall -ansi -pedantic foo.c
    foo.c: In function ‘cmd_line’:
    foo.c:31:21: warning: statement with no effect...
  18. Replies
    17
    Views
    483

    > printf ("%d\n", a[i]); Yah think this should...

    > printf ("%d\n", a[i]);
    Yah think this should be a different subscript as well?

    > for (b=0;b<9;b++)
    a[0] is already set, so perhaps this loop should start at 1.

    Also, think about what "this...
  19. Replies
    17
    Views
    483

    > a[i] = a[i]+2; Perhaps you should use [b] as...

    > a[i] = a[i]+2;
    Perhaps you should use [b] as your array subscript.
  20. Thread: ordering system

    by Salem
    Replies
    5
    Views
    224

    This is an error message. foo.c:82:11:...

    This is an error message.


    foo.c:82:11: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
    82 | if (flag = 0)
    | ^~~~


    You've posted...
  21. Thread: ordering system

    by Salem
    Replies
    5
    Views
    224

    What is the actual error message? How did you...

    What is the actual error message?

    How did you declare choice?

    What is ext() ?

    This isn't a game of 20 questions to try and get you to show a decent amount of information that would enable us...
  22. Thread: ordering system

    by Salem
    Replies
    5
    Views
    224

    Well you need to post more than the fragment of...

    Well you need to post more than the fragment of one line of code.
  23. > Program (probably scanf) provides corrupted...

    > Program (probably scanf) provides corrupted strings after 2nd loop.
    It's always the standard library used by millions every day without issue that's always a "problem".

    Never the noob with...
  24. At some point you need to be able to write your...

    At some point you need to be able to write your own code from first principles.

    Not just repost "found" code.

    Especially when said "found" code is full of nonsense.
  25. You start by drawing the problem out on paper,...

    You start by drawing the problem out on paper, then figuring out what you might need.


    int large[4][4] = {
    { 1, 2, 3, 4 },
    { 5, 6, 7, 8 },
    { 9, 10, 11, 12 },
    { 13,...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4