Search:

Type: Posts; User: seal308

Page 1 of 2 1 2

Search: Search took 0.01 seconds.

  1. Replies
    10
    Views
    11,430

    Ok i tried putting in mutexs for the code but I...

    Ok i tried putting in mutexs for the code but I don't think i get it still.
    I put a mutex called lock in the LL struct.



    long listSearch(listNodePtr listPtr, long key) {
    listNodePtr ...
  2. Replies
    10
    Views
    11,430

    Nvm i think i figured it out. While doing the...

    Nvm i think i figured it out.
    While doing the return the value can change.
  3. Replies
    10
    Views
    11,430

    Thread Safe Linked List

    Hello
    My teacher gave me sample code of a linked list thats not thread safe and told me to use pthreads mutex to make it thread safe
    Sample code:



    // routine to return the data from the node...
  4. Replies
    2
    Views
    2,705

    Thanks, this was a great help: Initialization...

    Thanks, this was a great help: Initialization Lists in C++ - Cprogramming.com
  5. Replies
    2
    Views
    2,705

    Trouble understanding constructor

    I'm new to c++.
    Here's the constructor I'm trying to understand:



    RealNum::RealNum(float initR) : r(initR) {}


    I don't understand the part that's : r(initR)
    What does it mean?
  6. Replies
    2
    Views
    2,270

    Nvm i figured it out. "Class" should go in the...

    Nvm i figured it out.
    "Class" should go in the header file and the not cpp file.
  7. Replies
    2
    Views
    2,270

    Basic Inheritence Question

    I am having trouble making a structure where Queue is a child of QueueItem, I get a "expected class name" error.
    I'm doing this in xCode.

    I have 4 files:
    Queue.cpp, Queue.h,...
  8. Replies
    3
    Views
    507

    Ok, thank you.

    Ok, thank you.
  9. Replies
    3
    Views
    507

    What does this typedef mean?

    Hello,

    I usually only use typedefs for structs
    eg) typdef struct STACK Stack;
    So I don't have to keep writing struct STACK everywhere.

    But I'm wonder what this typedef means:


    typedef int...
  10. Replies
    0
    Views
    372

    Pointer Type Question

    Hello,

    I am supposed to implement memory regions like this:
    https://en.wikipedia.org/wiki/Region-based_memory_management

    We are using a table that store the memory region name and a pointer to...
  11. Replies
    10
    Views
    2,900

    ok, will do, thanks for the advice.

    ok, will do, thanks for the advice.
  12. Replies
    10
    Views
    2,900

    Ok thank you. That seems to have worked. I just...

    Ok thank you.
    That seems to have worked.
    I just had the table.c and table.h file include the lifecycle.h file.
    eg


    #ifndef _TABLE_H
    #define _TABLE_H
    #include "lifecycle.h"
    ...
  13. Replies
    10
    Views
    2,900

    Actually I forgot to mention I'm supposed to use...

    Actually I forgot to mention I'm supposed to use the header file given for lifecycle.h and not change it.
    In that header file I have


    #ifndef _LIFECYCLE_H
    #define _LIFECYCLE_H


    typedef...
  14. Replies
    10
    Views
    2,900

    By guards do you mean this?: #ifndef...

    By guards do you mean this?:


    #ifndef _TABLE_H
    #define _TABLE_H




    #ifndef _LIFECYCLE_H
  15. Replies
    10
    Views
    2,900

    Header Files Typedef Redefintion

    Hello,

    I have 3 c files and 2 header files:
    main.c, lifecycle.c, table.c, lifecycle.h and table.h
    I worked on the table in a different problem with a different main and it works fine.

    The...
  16. Replies
    3
    Views
    2,259

    Thank you, this worked perfectly. I also had to...

    Thank you, this worked perfectly.
    I also had to made an change in the while token loop.


    while (token)
    {
    ...
    token = strtok(NULL, delims);
    }
  17. Replies
    3
    Views
    2,259

    strtok question

    Hello,

    I am trying to tokenize an input txt file by spaces.

    My code for it is:


    while ( fgets (input, LENGTH, inputTxt))
    {
    token = strtok(input, " ");
  18. Replies
    3
    Views
    1,668

    Ok thank you. I went through it with the lldb...

    Ok thank you.
    I went through it with the lldb debugger and everything is clear now.
    Because the node the newNode will point to has already been previously created I don't need to create new memory...
  19. Replies
    3
    Views
    1,668

    Struct Malloc question

    Hello,

    I have 2 structs


    struct CELL{
    int row;
    int column;
    };
    typedef struct CELL Cell;
  20. Replies
    3
    Views
    2,107

    Ok thank you.

    Ok thank you.
  21. Replies
    3
    Views
    2,107

    sizeof assertion problem

    Hello,

    In my program I would like to assert that the size of my array is what I told it to be as a precondition for a function.

    The function is:


    void getRow(char *token, char *input)
    {
    ...
  22. Thread: Why malloc?

    by seal308
    Replies
    5
    Views
    2,990

    Ok thx. So then for any pointer in a struct I...

    Ok thx.
    So then for any pointer in a struct I need to allocate memory for?

    So if my struct contained a int* pointer.
    Would the int it's pointing at need to be allocated as well?
    so...
  23. Thread: Why malloc?

    by seal308
    Replies
    5
    Views
    2,990

    This is sample code written by my teacher. He...

    This is sample code written by my teacher.
    He said you have to cast the return of malloc because malloc returns a void pointer.
    You're probably right, but maybe we just haven't got to that point....
  24. Thread: Why malloc?

    by seal308
    Replies
    5
    Views
    2,990

    Why malloc?

    struct STRING
    {
    int size;
    char *theString;
    };

    typedef struct STRING String;


    String * newString( char const * const init )
  25. Replies
    4
    Views
    3,009

    Thank you, I understand it perfectly now. It...

    Thank you, I understand it perfectly now.
    It clicked when you said that const applies to what is on its immediate left.
    It's easier for me to first think of it as empty of const so:

    void...
Results 1 to 25 of 45
Page 1 of 2 1 2