User Profile

Collapse

Profile Sidebar

Collapse
divideby0
divideby0
Last Activity: Nov 21 '14, 06:07 AM
Joined: May 30 '12
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • There is no standard way of replicating kbhit, getch, etc as the standard input functions are buffered and block while waiting on user input.

    I remember reading an article somewhere where buffering could be turned off, but it's not portable. Try milling over the results from google and see if any will work for your situation.

    Good luck
    See more | Go to post

    Leave a comment:


  • divideby0
    replied to How to count in Preprocessor C
    in C
    I don't know to be honest; looping and generating a returnable value has me stumped. I can only think of something like

    Code:
    #define SUM_X(struct_var)\
    (\
       (struct_var[0].x) + \
        ...\
       (struct_var[5].x)\
    )
    
    #define SUM SUM_X(my)
    SUM would still be treated as a non-constant, I believe, so int Newbuffer[SUM] probably wouldn't compile. Hopefully, donbock,...
    See more | Go to post

    Leave a comment:


  • divideby0
    replied to How to count in Preprocessor C
    in C
    I'm not sure that a macro works well for summing and returning a value. You might try a function instead.

    However you get the sum of ".x", you cannot size an array like you're wanting to do. Use dynamic allocation instead.

    Code:
    // declare struct
    ...
    
    int sumX(TYPE_TEST *arr, int arr_size)
    {
       // code to sum "x" and return its value
    }
    ...
    ...
    See more | Go to post

    Leave a comment:


  • srand doesn't return a value, but you're trying to assign it as though it did to nInRa. srand is your seed, which generally takes time(NULL) as its argument... include time.h or ctime

    you'd want rand to generate the "random" sequence.

    Code:
    srand((unsigned)time(NULL));
    
    nInRa = rand() % 3 + 1;
    See more | Go to post

    Leave a comment:


  • If you're wanting to allow alpha-numeric input, then you might try using a std::string or char array for order instead. Your sentinel would need modification though.

    A char type would work too, but leaves the little newline gremlin to deal with.
    See more | Go to post

    Leave a comment:


  • divideby0
    started a topic C and WinAPI: hwnd question

    C and WinAPI: hwnd question

    I've started working on win32 programming, and have a question regarding hwnds. I've milled over tutorials and they seem to vary - I've tried using the following 3 methods, but was wondering which, if any, is preferred?


    Code:
    ...
    static HWND hwnd1 = 0;
    ...
    WM_CREATE :
        hwnd1 = CreateWindow(...);
    ...
    Code:
    HWND function(...)
    {    
        return CreateWindow(...);
    ...
    See more | Go to post

  • divideby0
    replied to Convert String to integer ( hh/mm/ss )
    in C
    I think the op is wanting to parse the string to extract the integer values. if so, sscanf should work.
    See more | Go to post

    Leave a comment:


  • divideby0
    replied to moving starics
    in C
    you could probably get away with using two time_t objects to make a crude timer. it would be portable.

    #include <time.h>
    See more | Go to post

    Leave a comment:


  • divideby0
    replied to tutorial to learn php
    in PHP
    You might try looking here for the chm file, or here for the online version. Dunno about any tutorials.
    See more | Go to post

    Leave a comment:


  • getScore() needs access to your input file. since you've created the fstream object in main, you could modify getScore's parameter list to take "grades" as a second argument.
    See more | Go to post

    Leave a comment:


  • divideby0
    replied to program skipping lines
    in C
    check "b" to see if it's picking up the new line char instead of your expected input; mixing data types with scanf can be a nuisance.
    See more | Go to post

    Leave a comment:


  • divideby0
    replied to BMI Calculator problem
    in C
    You can use a variable to count the lines as you read the contents of the file. It sounds like it should be the index position for the array as you read the file.

    the read_data function looks incomplete; what value does the return represent? the status of the file? the number of elements to read? some other value?

    as a side note, like sscanf and scanf, fscanf returns the number of successfully converted and stored...
    See more | Go to post

    Leave a comment:


  • divideby0
    replied to BMI Calculator problem
    in C
    The errors occur because your prototype doesn't match your call. The prototype takes two floats as arguments and returns a float; neither the return value nor the argument list should be float arrays.

    Code:
    float compute_bmi(float, float);
    you're trying to do below, but it is incorrect for the function prototype and its definition.
    Code:
    array = compute_bmi(array, array);
    height, weight, and bmi have all...
    See more | Go to post

    Leave a comment:


  • divideby0
    replied to BMI Calculator problem
    in C
    Your best bet would be to copy / paste any compiler errors in your topic. If the code you posted is the same as the compiler errors, then line 10 *looks* okay.

    line 28 has an issue. The prototype returns a float and not an array; however, I don't believe C allows aggregate assignment of arrays. wfc??
    See more | Go to post

    Leave a comment:


  • divideby0
    replied to How can I fix my compiling error on line 12?
    in C
    Code:
     input(message[100], key);
    the call here isn't right. you haven't declared any variables named input or key. declare a char array and an integer variable, and pass them as parameters to input.

    Code:
    char array[100] = { 0 };
    int key;
    
    input(array, key);
    Code:
    void input(char message[100], int& key)
    {
    cout << "Please enter an encrypted message:
    ...
    See more | Go to post

    Leave a comment:


  • With VS, you should be able to include windows.h and link kernel32.lib to your application for FindFirstFile, FindNextFile, etc.

    Code:
    #include <windows.h>
    
    #pragma comment(lib, "kernel32")
    
    // program code
    For the other, I cannot recall if you mentioned whether or not you were using c or c++, but you can build the dir command using sprintf or sprintf_s
    ...
    See more | Go to post

    Leave a comment:


  • If you're using VS, then you should be able to make use of CreateFile, FindFirstFile and FindNextFile for processing directories and files. The links have examples for doing what you're trying to do.

    The only other thing I can think of is to build a command string for DIR, and pass the arugments using system. You can dump the result to a file instead of the console window, which you could then open, read, and process as needed....
    See more | Go to post

    Leave a comment:


  • divideby0
    replied to thread appears to run after SetEvent
    in C
    I wish that I could learn to think like a programmer; thank you for that! Just what it needed. :)

    Cheers
    See more | Go to post

    Leave a comment:


  • divideby0
    replied to thread appears to run after SetEvent
    in C
    Thank you for the reply... as always, I appreciate your time and feedback.

    The problem went away after moving the (tmp->canceled == TRUE) test to the bottom of the do-while. I still have no clue as to way the program bogged down if that test was at the top of the loop.

    SetEvent was called within one of the WM_USER messages. The thread ended, but had a sort of delayed effect before. Moving the canceled test "fixed...
    See more | Go to post

    Leave a comment:


  • divideby0
    started a topic thread appears to run after SetEvent
    in C

    thread appears to run after SetEvent

    I don't know if I've setup the thread correctly or not, but its behavoir isn't what I'd expect. I'm creating the thread within a BN_CLICKED message

    Code:
    typedef struct my_TNFO
    {
        HANDLE h_event;
        HANDLE h_thread;
        DWORD  thread_id;
        BOOL   running;
        BOOL   init;
        BOOL   canceled;
    } TNFO;


    Code:
    ...
       if(HIWORD(wParam)
    ...
    See more | Go to post
No activity results to display
Show More
Working...