Search:

Type: Posts; User: thmm

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Replies
    3
    Views
    357

    I am not sure if it is worth for a beginner to...

    I am not sure if it is worth for a beginner to bother about.
    But if you insist, there is an example: C library function - setvbuf() - Tutorialspoint
  2. Thread: Binary file

    by thmm
    Replies
    11
    Views
    476

    As far as I see it seems ok, but I am not an...

    As far as I see it seems ok, but I am not an expert.
  3. Thread: Binary file

    by thmm
    Replies
    11
    Views
    476

    I guess the op wants to run it only on his...

    I guess the op wants to run it only on his machine so this assumptions are justified.
  4. Thread: Binary file

    by thmm
    Replies
    11
    Views
    476

    Looks better now, but one problem remains. if...

    Looks better now, but one problem remains.

    if (file1 == NULL && file2 == NULL && file3 == NULL) {
    Shouldn't the conditions be || since if one file can't be opened there is no point to continue.
  5. Thread: Binary file

    by thmm
    Replies
    11
    Views
    476

    book.category == "Software Engineering" This...

    book.category == "Software Engineering"
    This doesn't not work. To compare strings you need to use strcmp.

    Your compiler should warn you.
    gcc -Wall -Wextra "binary.c" -std=c99 -o file_demo.exe...
  6. Why not ? From a OO point a player has an...

    Why not ? From a OO point a player has an inventory.
    I would rather decouple the player from the inventory, the inventory doesn't need to know the player class.
  7. Replies
    10
    Views
    852

    If you have an abstract function in the base...

    If you have an abstract function in the base class you need a virtual constructor.
    c++ - When to use virtual destructors? - Stack Overflow

    I also would replace the dynamic array with a...
  8. Replies
    12
    Views
    451

    What is the problem? Does it crash? Does it...

    What is the problem?
    Does it crash?
    Does it allow more than 7 tries?
    Doesn't it guess it at all?

    One problem I see is that you set high to 100, but the user can enter sth. like 55.
  9. I think you need to learn how to enable warnings...

    I think you need to learn how to enable warnings in your code flags. Your code has quite a few errors.

    clang -Wall -Wextra -Wshadow -Wpedantic -Werror -std=c99 -fsanitize=address,undefined -c...
  10. Replies
    2
    Views
    451

    Also posted here: C Programming Linked List - C...

    Also posted here:
    C Programming Linked List - C And C++ | Dream.In.Code
  11. Thread: Composition

    by thmm
    Replies
    11
    Views
    985

    @laserlight, I just wanted to show an...

    @laserlight,
    I just wanted to show an alternative way to do certain things.
    I don't claim that it is better.
    Not needing inheritance is a just a nice side ffect.
    I guess that not using virtual...
  12. Thread: Composition

    by thmm
    Replies
    11
    Views
    985

    An alternative without virtual functions and...

    An alternative without virtual functions and pointers is to use std::variant and std::visit - since C++17.


    #include <iostream>
    #include <vector>
    #include <variant>


    class Vehicle
    {
  13. Replies
    24
    Views
    1,954

    VS 2019 16.8.4 gives me this warning with /W4:...

    VS 2019 16.8.4 gives me this warning with /W4: warning C4189: 'i': local variable is initialized but not referenced
    You probably need to enable Code Analysis on Build under Code Analysis in the...
  14. Replies
    9
    Views
    906

    That was my idea: #include #include...

    That was my idea:


    #include <stdio.h>#include <string.h>


    void repeat(const char* input, char *output)
    {
    int n = 0;
    char buffer[32] = {'\0'};
  15. Thread: Just starting

    by thmm
    Replies
    17
    Views
    1,150

    I don't think it has anything to do with the...

    I don't think it has anything to do with the language, it has more to do about thinking clearly. Python would be easier to learn because you don't need manual memory management, it also has build-in...
  16. Thread: Just starting

    by thmm
    Replies
    17
    Views
    1,150

    @john.c why do you mention books about C++ when...

    @john.c
    why do you mention books about C++ when he wants to learn C ?
  17. Replies
    9
    Views
    906

    I rather would do it like this: #ifdef...

    I rather would do it like this:


    #ifdef _MSC_VER
    #define _CRT_SECURE_NO_WARNINGS
    #endif

    #include <stdio.h>
    #include <conio.h>
    #include <string.h>
  18. Thread: arrays

    by thmm
    Replies
    7
    Views
    447

    6356672 was the address of array1. If you want...

    6356672 was the address of array1. If you want the actual number you have to use the subscript operator, like array1[0], array1[1]...
    I would recommend that you get a (e)book. Just guessing how...
  19. Thread: printf int

    by thmm
    Replies
    2
    Views
    342

    You need a format specifier in your printf. ...

    You need a format specifier in your printf.

    printf("1+2= %d", int3);
  20. Thread: Copy function

    by thmm
    Replies
    2
    Views
    433

    You need to copy the values from arr1 to arr2...

    You need to copy the values from arr1 to arr2 only if they are greater than threshold. There is no need to find the min.

    Maybe sth. like this:


    for (int i = 0; i < length; ++i) {
    if...
  21. You are right. Thanks for pointing it out.

    You are right. Thanks for pointing it out.
  22. Wouldn't it be possible to set the locale to a...

    Wouldn't it be possible to set the locale to a country that uses the comma as decimal separator and read the input as a flaot ?
  23. Replies
    8
    Views
    611

    When I ran the code in VS 2019 I got an exception...

    When I ran the code in VS 2019 I got an exception at line 85

    strcpy(A[index].name, temp.name);
    when index was -307.
  24. Thread: I've been stuck.

    by thmm
    Replies
    6
    Views
    848

    Have a look at this tutorial. It uses an int for...

    Have a look at this tutorial. It uses an int for the data but you could modify to use strings.
    Given a linked list which is sorted, how will you insert in sorted way - GeeksforGeeks
  25. Replies
    5
    Views
    640

    Why not follow the KISS priciple? #define...

    Why not follow the KISS priciple?



    #define NAME_LEN 100
    char first_name[NAME_LEN];
    scanf("%99s", first_name);
Results 1 to 25 of 60
Page 1 of 3 1 2 3