Search:

Type: Posts; User: Nightowl

Page 1 of 8 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    5
    Views
    4,711

    For (a little) more detail on how to get this...

    For (a little) more detail on how to get this sort thing working in C++ . . .

    Due to Name mangling, C++ function names are changed to a form not easily rememberable. Therefore, instantiating a...
  2. Replies
    2
    Views
    6,294

    Would "%02X" not work?

    Would "%02X" not work?
  3. Replies
    17
    Views
    14,808

    If the return value of fread is less than the...

    If the return value of fread is less than the total number that you asked for, then you're looking at an EOF being entered.

    Make sense?
  4. Replies
    17
    Views
    14,808

    It returns the number of characters (excluding...

    It returns the number of characters (excluding the EOF) that were successfully read.
  5. . . . could be replaced by something like . . . ...

    . . . could be replaced by something like . . .



    cat a.mp3 > output.mp3
    cat t.mp3 >> output.mp3


    . . . which is a little bit more efficient and smaller. ;)
  6. Replies
    17
    Views
    14,808

    Good question. I've no idea . . . Well, it's a...

    Good question. I've no idea . . .

    Well, it's a safe bet, that if fread returns EOF, then you've got less than 128 chars in there . . .

    But, since the puts works correctly, I'd say it's nice...
  7. Replies
    4
    Views
    1,494

    You'll want strncpy...

    You'll want strncpy instead of strcpy, I believe. No?
  8. Replies
    1
    Views
    949

    If you have a set of data . . . say, in an array...

    If you have a set of data . . . say, in an array of something much like this structure . . .


    struct plot_point_t {
    double xpos, ypos;
    };

    . . . then, it's really quite simple. Well,...
  9. Replies
    3
    Views
    2,643

    Correct, unless the original int value was less...

    Correct, unless the original int value was less than 256, in which case the data will be unchanged.

    EDIT: assuming you mean "cast it back to an int", not a uchar.
  10. Replies
    1
    Views
    953

    Well, something to consider is that you will want...

    Well, something to consider is that you will want that code in a loop of sorts, such as . . .

    (pseudocode, not real C!)


    first = 1
    do {
    if(!first) explain_error()
    print_prompt()
    ...
  11. Replies
    17
    Views
    14,808

    . . . #include int main(int...

    . . .



    #include <stdio.h>

    int main(int argc, char *argv[]) {
    char s[128] = {0};
    fread(s, sizeof(char), 128, stdin);
    puts(s);
  12. Replies
    3
    Views
    2,643

    Yeah, that condition will always be true. If...

    Yeah, that condition will always be true.

    If you want to compare an int and a uchar, then something like this would work:



    if((int)ucharvariable < intvariable) /* do stuff */


    . . ....
  13. Replies
    17
    Views
    14,808

    . . . then it will continue to wait until 256...

    . . . then it will continue to wait until 256 characters are in the buffer, I do believe. Why not try it yourself?

    You may be wanting fgets instead?
  14. Thread: Stringstream

    by Nightowl
    Replies
    9
    Views
    5,555

    If you're looking for something an append...

    If you're looking for something an append function for a string, go something like this.



    int append(char *str, size_t strsize, char *toappend) {
    if(str == NULL || toappend == NULL) return...
  15. Replies
    4
    Views
    1,238

    void process() { for (name;

    void process()
    {
    for (name; <10; name+1)
    printf("Your name is %s/n",name);
    }


    That section has a few bugs in it . . .

    First off . . . for (name; <10; name+1) is incorrect. Try for (;...
  16. mpg123 is a linux mp3 player...

    mpg123 is a linux mp3 player.
  17. Replies
    2
    Views
    976

    Well, it's quite simple. Create a struct that...

    Well, it's quite simple.

    Create a struct that stores the names and each value from the files, as well as the ID of that entry. Create an array of them. (Hopefully using memory allocation). Could...
  18. Replies
    14
    Views
    1,042

    What transgalatic is doing, is saying that it...

    What transgalatic is doing, is saying that it takes too much time to calculate the output in an exam, where everything is time-critical.

    Try it for the cases of (1,1), (1, 2), (2, 1), (2, 2), (3,...
  19. Replies
    5
    Views
    1,480

    This problem is quite simple . . . Assuming...

    This problem is quite simple . . .

    Assuming you're working a maximum size of, say, 32. (unsigned long int, in other words)


    (yes, I *know* that long is the same thing as int on most modern...
  20. Replies
    25
    Views
    2,079

    As I pointed out in maybabier's other thread,...

    As I pointed out in maybabier's other thread, there is a good guide to indentation here.

    It really helps with debugging, trust me. The extra 20 seconds it takes to indent everything to the proper...
  21. Replies
    18
    Views
    3,570

    Isn't it already int? Oh, whoops. My bad. ...

    Isn't it already int?

    Oh, whoops. My bad.

    Yeah, getchar() returns an integer, and as vart points out, EOF is (usually) declared as -1. Therefore, if you typed in a 0xFF char (very unlikely...
  22. I would highly recommend learning C *before*...

    I would highly recommend learning C *before* digging into how UNIX and operating systems work.

    You end up learning how Linux works when you start digging into sockets and such in C anyhow. ;)
  23. Replies
    7
    Views
    1,359

    Read it into a character array like this . . . ...

    Read it into a character array like this . . .

    (note that some of this is invalid, but changed for easier reading)


    char number[1024];
    scanf("%s", number);
    /* and now you've got a nice,...
  24. Replies
    4
    Views
    1,290

    This is the most major disadvantage of using char...

    This is the most major disadvantage of using char *string = "STRING";.

    Use something more like



    char string[128] = "string";


    . . . if you must.
  25. Thread: help needed

    by Nightowl
    Replies
    3
    Views
    1,013

    Was there a purpose to that response? Is it...

    Was there a purpose to that response? Is it asking for elaboration?

    I'm going to assume so.

    I'm also going to assume that this is homework. Therefore, I'm not going to give you a solution to...
Results 1 to 25 of 187
Page 1 of 8 1 2 3 4