Search:

Type: Posts; User: c99tutorial

Page 1 of 20 1 2 3 4

Search: Search took 0.04 seconds.

  1. Don't copy something that doesn't make sense for...

    Don't copy something that doesn't make sense for your problem, and don't use classes just because someone said they're a good idea. Start with simple classes that help simplify notation or help you...
  2. Replies
    1
    Views
    3,806

    Try the C Book Recommendations...

    Try the C Book Recommendations sticky thread at the top of this forum. Examples: The C Programming Language (Kernighan and Ritchie), C Programming: A Modern Approach (King), Algorithms in C...
  3. Replies
    9
    Views
    5,955

    Try Qt Creator. It works well for C and C++...

    Try Qt Creator. It works well for C and C++ whether or not you use Qt. One of the packages also comes bundled with MinGW for Windows, which is pretty convenient.
  4. Replies
    6
    Views
    1,923

    fgets is not guaranteed to write a '\0' byte to...

    fgets is not guaranteed to write a '\0' byte to the buffer, so strlen is not guaranteed to work. Hence this line:



    message[sizeof(message)-1] = '\0'; // Ensure '\0' termination.


    After...
  5. Replies
    6
    Views
    1,923

    The %s scanf format stops reading on a space. If...

    The %s scanf format stops reading on a space. If you want to continue reading after the space, you have a few options:

    1. Simple workaround is to replace %s with the %[...] syntax to coax scanf to...
  6. Replies
    3
    Views
    4,820

    If you dislike the book, why do you want...

    If you dislike the book, why do you want something like it?
  7. Replies
    1
    Views
    2,036

    1. The specification demands a period and space...

    1. The specification demands a period and space must follow the line number. Therefore, your format should be:



    fprintf(pFileOut, "%d. %s", nrline, string);


    2. Enable warnings and fix the...
  8. When teaching, try to keep the examples simple....

    When teaching, try to keep the examples simple. For example, show how to print a string forward and reverse, and you can already talk about a lot of things, like functions, strings, string length,...
  9. Replies
    6
    Views
    6,162

    The label should be local to a function. It does...

    The label should be local to a function. It does not have a type, it is just a label. e.g.




    int my_function()
    {
    ...
    goto some_label;
    ...
  10. Replies
    6
    Views
    6,162

    You can create a label and use goto to jump to...

    You can create a label and use goto to jump to it. Some consider this bad style, but sometimes it is very useful.



    while(1)
    {
    ...
    {
    switch (ucHexDigit)
    {
  11. Replies
    8
    Views
    3,328

    Stroustrup publishes the exercises in a separate...

    Stroustrup publishes the exercises in a separate document on his Web site. It is based on TC++PL 4th edition, so some chapter numbers may be different in the Tour book.

    Stroustrup: A Tour of C++
  12. Replies
    1
    Views
    8,356

    If you want to use a library you should look at...

    If you want to use a library you should look at NCurses or PDCurses, both freely available. The Curses API has functions called "box" and "border" for drawing such lines, as well as a lot more...
  13. Replies
    8
    Views
    4,437

    The problem with this benchmark is that you're...

    The problem with this benchmark is that you're launching awk 10000 times to do a very small amount of work. I would imagine most of the execution time of this would be spent creating and destroying...
  14. Replies
    3
    Views
    6,380

    Here is an alternative. All you need to do is...

    Here is an alternative. All you need to do is call vprintf followed by some code which outputs a newline. You don't need buffers or anything like that. If you are using GCC you can even get it to...
  15. Replies
    2
    Views
    5,245

    Learn how to turn on compiler warnings. For your...

    Learn how to turn on compiler warnings. For your example, the compiler will help you. For example GCC says the following:



    main.c:7:19: warning: operation on 'x' may be undefined...
  16. See: FAQ > main() / void main() / int main() /...

    See: FAQ > main() / void main() / int main() / int main(void) / int main(int argc, char *argv[]) - Cprogramming.com
  17. Replies
    5
    Views
    5,315

    The stdio library (f* functions) already do...

    The stdio library (f* functions) already do buffering for you, so there is nothing wrong with processing one byte at a time. For example, if you want to capitalize every letter in the file, this is...
  18. You could start with this simple organization and...

    You could start with this simple organization and then modify it as you see fit:

    main.c <-- this #include's other .h files

    module1.h
    module1.c

    module2.h
    module2.c
  19. Replies
    5
    Views
    5,315

    You may not even need seeking to do what you...

    You may not even need seeking to do what you describe. You could just read a byte at a time sequentially and write it out.

    If you do want to seek, though, see rewind(3): reposition stream - Linux...
  20. Replies
    15
    Views
    6,366

    How many logical lines is this? printf(...

    How many logical lines is this?



    printf(
    "hi"
    );


    And this?
  21. This is why using using namespace std is a boon....

    This is why using using namespace std is a boon. Don't listen to the Internet when they tell you not to use it.
  22. Replies
    6
    Views
    2,383

    No. Pedantic means to warn you about things that...

    No. Pedantic means to warn you about things that might violate the Standard. For example -pedantic should warn if you use // ... style comments when compiling with C89 mode.
  23. Replies
    4
    Views
    3,346

    For plotting you could take a look at gnuplot...

    For plotting you could take a look at gnuplot and/or mathgl.
  24. Replies
    5
    Views
    4,022

    1. For C++ you write #include 2. Yes....

    1. For C++ you write #include <cassert>
    2. Yes. It is pretty convenient. If you don't want to add string literals to your assert statements another approach is to write descriptive names for the...
  25. Replies
    4
    Views
    3,614

    Why did you title this Qt. Do you want someone to...

    Why did you title this Qt. Do you want someone to comment on how to use Qt APIs to read the file? Write your attempt first using Qt APIs and someone can suggest improvements.
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4