Search:

Type: Posts; User: Salem

Page 1 of 20 1 2 3 4

Search: Search took 0.17 seconds.

  1. > Is there any way I could have grouped the...

    > Is there any way I could have grouped the letter int variable,
    Yeah, they're called arrays.



    int digits[16];

    /*
    i = ccnum % 10;
    j = ccnum % 1000 / 100;
  2. packet.append(0xBF) packet.append(0xAB) ...

    packet.append(0xBF)
    packet.append(0xAB)
    packet.append(0xCD)
    packet.append(0xEF)
    Well since these aren't printable characters, what were you expecting?

    Instead of

    ...
  3. Except things like threads, concurrency and...

    Except things like threads, concurrency and synchronisation are more like platform issues rather than compiler issues.

    > uint pos = ++(zque->que);
    If you let two threads pointing at the same zque...
  4. Why aren't you using actual pthread primitives?

    Why aren't you using actual pthread primitives?
  5. Thread: Struct.

    by Salem
    Replies
    11
    Views
    148

    Circular linked lists are a bit of a pain,...

    Circular linked lists are a bit of a pain, especially if you care about element order.
    Linked list - Wikipedia

    A simple example.


    #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
  6. Replies
    14
    Views
    252

    I guess it would be something like this ...

    I guess it would be something like this


    if (opt == 'a') {
    for (i = 0; i < num; i = i + 1) { // reading 5 values from user and storing it in array
    printf(" Enter the value...
  7. Replies
    14
    Views
    252

    No, there are 10 different places where you make...

    No, there are 10 different places where you make the same mistake.


    $ gcc -Wall -Wextra -c main.c
    main.c: In function ‘As5GradeB’:
    main.c:18:11: warning: format ‘%d’ expects argument of type...
  8. Replies
    14
    Views
    252

    > scanf("%d", &a); All your references to your...

    > scanf("%d", &a);
    All your references to your array should have a subscript.
    As in
    scanf("%d", &a[i]);
  9. Replies
    2
    Views
    129

    > root@ And create yourself a proper user...

    > root@
    And create yourself a proper user account for your day to day activities.
  10. Replies
    6
    Views
    173

    You have to think about what this leaves on the...

    You have to think about what this leaves on the input stream
    > scanf("%d", &choice);

    To understand what this actually means
    > scanf("%[^\n]%*c", uname);

    The \n that the %d conversion leaves...
  11. Replies
    6
    Views
    173

    Pretty much. printf("\033[2J"); // should also...

    Pretty much.

    printf("\033[2J"); // should also clear the screen.
    printf("\033[H"); // move cursor home

    ANSI escape code - Wikipedia
  12. Replies
    4
    Views
    137

    So in a very basic sense, you could do this. ...

    So in a very basic sense, you could do this.


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

    void input( char ***ptr ) {
    *ptr = malloc( sizeof(**ptr) );
    (*ptr)[0] = malloc(...
  13. Replies
    4
    Views
    137

    What sort of help do you need? Is it...

    What sort of help do you need?

    Is it everything, or just the finer detail of dealing with three stars and malloc?

    Can you for example complete the assignment if you started with
    char...
  14. > However the danger with allocating on the stack...

    > However the danger with allocating on the stack is that of stack smashing, a very big danger indeed.
    No less dangerous than heap smashing, but certainly more immediately obvious.
    If you write bad...
  15. Replies
    6
    Views
    219

    1. Better indentation - Indentation style -...

    1. Better indentation - Indentation style - Wikipedia
    Pick a style and stick to it.
    In particular, do not mix spaces and tabs. Your code editor might make a decent job of it, but as soon as you...
  16. Replies
    6
    Views
    173

    There's no such thing as a page in simple console...

    There's no such thing as a page in simple console programming.
    It's all just one continuous scrolling stream of text.

    You can get the 'page' feel by finding out whatever 'clear screen' option...
  17. Replies
    6
    Views
    219

    Please paste your code as text, not whatever...

    Please paste your code as text, not whatever weird markup you're using.
  18. Replies
    6
    Views
    219

    I would suggest starting with a simple example,...

    I would suggest starting with a simple example, then adapt slowly towards your goal.


    #include <stdio.h>
    #include <unistd.h>
    #include <pthread.h>

    pthread_cond_t c_ping =...
  19. Replies
    3
    Views
    143

    Something like this? #define STR(x) #x...

    Something like this?



    #define STR(x) #x
    #define COMMAND(dir) "find " STR(dir) " -type f -printf '%T@ %t %p\\n' | sort -k 1 -nr | rev | cut -d' ' -f1 | rev"
    #define DIRECTORY...
  20. Replies
    1
    Views
    247

    Like this? Accessing command line...

    Like this?
    Accessing command line parameters/arguments - Cprogramming.com

    > Setting a countdown timer in C++?
    None of your actual code is C++ code at all.
    It's all 'C' code.
  21. Thread: MX component

    by Salem
    Replies
    3
    Views
    251

    So where did you get your MX tool from? MX...

    So where did you get your MX tool from?

    MX Component Features of the software Programmable Controllers MELSEC | MITSUBISHI ELECTRIC FA
    Two things come to mind.

    1. This is the kind of niche...
  22. Replies
    17
    Views
    383

    //open files for reading and writing FILE...

    //open files for reading and writing
    FILE *out = fopen("sim_output.txt", "w");
    FILE *in_t = fopen("sim_input.txt", "r");
    if (in == NULL && out == NULL) //Check if files exists before...
  23. Replies
    6
    Views
    206

    int doves = 0; int hawks = 0; ...

    int doves = 0;
    int hawks = 0;
    int maxConnections = 0;

    for (int i = 0; i < playerCount; i++)
    {
    if (players[i].strat == HAWK)
    {
    ...
  24. Replies
    6
    Views
    206

    At first glance, it seems most of your memory...

    At first glance, it seems most of your memory allocations are broken.


    $ valgrind ../a.out
    ==13564== Memcheck, a memory error detector
    ==13564== Copyright (C) 2002-2015, and GNU GPL'd, by...
  25. Thread: memcpy usage

    by Salem
    Replies
    2
    Views
    143

    Well memcpy(m, k, sizeof(m)) is memcpy(m,...

    Well
    memcpy(m, k, sizeof(m))
    is
    memcpy(m, &k[0], sizeof(m))


    So
    memcpy(m, &k[3], sizeof(m))
    is entirely reasonable.
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4