User Profile

Collapse

Profile Sidebar

Collapse
AmeL
AmeL
Last Activity: Jan 25 '10, 07:17 AM
Joined: Oct 27 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • AmeL
    replied to socket and pthread
    in C
    Anyway, how about the same resource shared by two threads ?
    I have to use the pthread_mutex_t to lock it right ?
    I am not sure when to lock the resource. Let's say, there are 2 threads, one is to write data, and another is to read data, so in either reading or writing, we lock the resource ? or we lock only when we write ?
    See more | Go to post

    Leave a comment:


  • AmeL
    replied to socket and pthread
    in C
    Thank gpraghuram
    oh yes....you're right. I forget to set the attribute to be JOINABLE, and join them to the main thread, so that the main thread could wait for all of the child threads to be terminated.
    See more | Go to post

    Leave a comment:


  • AmeL
    started a topic socket and pthread
    in C

    socket and pthread

    Hi all.
    I have a socket. I want to create two threads, one is to read from socket, and another is to write to socket. However, I want these two threads to be able to share the same data, so I created a mutex to lock the resource.
    I don't know what happens with my two threads, but it always quits after it did some tasks.
    Code:
    #include "camel.h"
    #include "irc.h" 
    
    pthread_t         gtid;
    ...
    See more | Go to post

  • AmeL
    replied to UnboundLocalError
    Oh god
    The problem is at last solved, I forgot to import a module named inspect :)
    See more | Go to post

    Leave a comment:


  • AmeL
    started a topic UnboundLocalError

    UnboundLocalError

    I am stuck at the a small code as the following:

    This is module main, the main entry of the application :
    Code:
    from irc_log_mod import *
    from irc_chatter_mod import *
    from inspect import *
    from irc_global_mod import *
    
    def main():
        try:
                curFrame = currentframe()
                writeLog(LOG,
                         curFrame.f_code.co_filename,
    ...
    See more | Go to post

  • AmeL
    replied to dereferencing void pointers by typecasting
    in C
    Code:
    void *xyz;
    struct abcd
    {
    int a;
    };
    struct abcd a,*ptra;
    ptra=&a;
    xyz=(struct abcd *)ptra; //doesnt work but no error shown.
    .
    .
    printf("%d \n",xyz->a);
    }
    Let review your code a bit more!!!
    You declared xyz as a pointer to void.
    Then after you do like :
    xyz = (struct abcd *)ptra; that ptra's type is a pointer...
    See more | Go to post

    Leave a comment:


  • AmeL
    replied to Regarding log file
    in C
    In the log file, there should be included :
    - date of logging
    - file : in what file that produces the log ?
    - function : in what function ?
    - line : the line number
    - debug level : in which level is this log ?
    - status : success... failed, ... error code ...etc
    - desc : the error description.
    This is the incomplete sample code to log something:
    Code:
    Full code removed, please read posting guidelines
    ...
    See more | Go to post

    Leave a comment:


  • AmeL
    replied to How To Access Dll Files In C++
    in C
    Well, this command below works with GCC.
    Example :
    - path_header_fil e : the path to header files of that library
    - path_lib
    - name_of_lib : the file name of .lib
    so the command built against that library is :
    gcc -Ipath_header_fi le -Lpath_lib -lname_of_lib -o your_source your_source.c

    If that goes smoothly, copy the DLL file ( always provided with the library ) to the same directory of your...
    See more | Go to post

    Leave a comment:


  • AmeL
    replied to How To Access Dll Files In C++
    in C
    The library are of two kinds static and dynamic library
    The static library which is known as .lib on window platform and .a on Unix-like system. the static library is needed in the linking phase after you have compiled your code successfully because only the library can understand what have to do with the function you called in your source code. The linker, may be, read through your object file and copy the function implementation in the library...
    See more | Go to post

    Leave a comment:


  • AmeL
    replied to how to solve this 2 errors ?
    in C
    Please look at this
    Code:
    ...........................................................
    void input_data(struct database*data_ptr)
    {
    int i_tmp;
    float f_tmp;
    string s_tmp;
    cout<<"enter name:";
    cin >>s_tmp;data_ptr->name = s_tmp;
    cout << "enter id_number :";
    cin >> i_tmp;data_ptr->id_number = i_tmp;
    cout << "enter
    ...
    See more | Go to post

    Leave a comment:


  • Could you please put the code bracket around your code for readability; and write us the error message which compiler produce ( with line number ) to make us easy to solve your problem, if that is a syntax error ?
    See more | Go to post

    Leave a comment:


  • AmeL
    replied to Need help with a c++ program quitting
    in C
    Well, I find nothing wrong with your code beside the incompatibility of the data type u declared and the inputted data.
    Example :
    MONSTER : should be declare as an array of char not char.
    So please reconsider this case again.
    NOTE : One more thing, I would like to say that even your data type should be integer, yet you have to declare it as an array of char to prevent any unexpected error occurred when user input the char...
    See more | Go to post

    Leave a comment:


  • AmeL
    replied to Sentence Encryption in C++
    in C
    As you mentioned above, the designed constraint only allows the string input and never number type. so i better not speak something about this ( but wait you should consider this case too before shipping your .exe to your customer).
    Yet I found another problem with this
    How can u decrypt this data : 334 ?
    if you split like this 3, 3 and 4 so it will be CCD
    if that comes to 3, and 34 so it will be Cb
    and if that...
    See more | Go to post

    Leave a comment:


  • Yep you can prompt a user to press any key before exiting; yet you can launch your command prompt and execute your .exe to see what is displayed.
    However ( this is not what you asked for ), I found that your code does not really count the number of vowels or consonant of the inputted string from users. It had better that you redesign your code again to make it work as what is required.
    See more | Go to post

    Leave a comment:


  • AmeL
    replied to Unresolved external symbol error :-(
    in C
    Code:
    main.obj : error LNK2001: unresolved external symbol "private: static int * * Binary::mask" (?mask@Binary@@0PAPAHA)
    fatal error LNK1120: 1 unresolved externals
    Well, the error happens when your linker tries to link your object file ( let says main.o) with the library and with something you have implemented. When the linker read Binary::InitMas k(), it can not find where the implementation of InitMask() is. So the linking...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...