Search:

Type: Posts; User: Salem

Page 1 of 20 1 2 3 4

Search: Search took 0.19 seconds.

  1. Why aren't you using actual pthread primitives?

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

    by Salem
    Replies
    11
    Views
    130

    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>
  3. Replies
    14
    Views
    232

    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...
  4. Replies
    14
    Views
    232

    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...
  5. Replies
    14
    Views
    232

    > 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]);
  6. Replies
    2
    Views
    112

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

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

    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...
  8. Replies
    6
    Views
    158

    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
  9. Replies
    4
    Views
    126

    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(...
  10. Replies
    4
    Views
    126

    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...
  11. > 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...
  12. Replies
    6
    Views
    212

    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...
  13. Replies
    6
    Views
    158

    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...
  14. Replies
    6
    Views
    212

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

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

    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 =...
  16. Replies
    3
    Views
    134

    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...
  17. Replies
    1
    Views
    230

    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.
  18. Thread: MX component

    by Salem
    Replies
    3
    Views
    235

    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...
  19. Replies
    17
    Views
    379

    //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...
  20. Replies
    6
    Views
    204

    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)
    {
    ...
  21. Replies
    6
    Views
    204

    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...
  22. Thread: memcpy usage

    by Salem
    Replies
    2
    Views
    142

    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.
  23. Replies
    6
    Views
    204

    Well before you get to run anything, fix all the...

    Well before you get to run anything, fix all the warnings (which are errors).


    $ gcc -std=c99 -Wall -Wextra bar.c -lm
    bar.c: In function ‘AddConnection’:
    bar.c:65:9: warning: assignment from...
  24. Replies
    17
    Views
    379

    > I'm using cygwin to test this code since I'm...

    > I'm using cygwin to test this code since I'm using windows.
    Yeah, a lot of this stuff isn't going to work in cygwin.

    You'll be better off installing WSL or using VirtualBox for that authentic...
  25. First I would suggest you simplify the code you...

    First I would suggest you simplify the code you have - by making all those parameters not actually used for passing parameters into local variables.



    void genpass (int i, int password)
    {
    ...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4