Search:

Type: Posts; User: Salem

Page 1 of 20 1 2 3 4

Search: Search took 0.64 seconds.

  1. Replies
    2
    Views
    92

    Do you have lots of global variables as well as...

    Do you have lots of global variables as well as functions?

    It's generally simpler if you restrict the first pass through the code to only move functions that don't depend on global variables.
    ...
  2. Replies
    2
    Views
    144

    A couple of things. 1. The input needs to be...

    A couple of things.

    1. The input needs to be non-blocking
    c - How to read terminal's input buffer immediately after keypress - Stack Overflow

    2. printf("%s", c);
    Use %c, not %s
    What you have...
  3. Replies
    15
    Views
    241

    Forget it's a file, what would you do if you had...

    Forget it's a file, what would you do if you had


    struct studentdata students[7] = {
    };

    initialised with the 7 student numbers you showed us.

    You'd probably end up with
  4. Replies
    15
    Views
    241

    > If i input 95 i'm trying to get fseek to point...

    > If i input 95 i'm trying to get fseek to point to the structure containing that student number, instead of the struct that's the 1st, 2nd, 3rd, etc
    Then you have to read each record in turn, and...
  5. Replies
    15
    Views
    241

    >I'm not understanding what you mean by your...

    >I'm not understanding what you mean by your first sentence, as &edit_student is supposed to be the input from the user to select the structure to edit
    If you want to edit the first record, do you...
  6. Replies
    15
    Views
    241

    Both are correct, depending on whether...

    Both are correct, depending on whether edit_student starts at 0 or 1 (think arrays).

    The other things to remember are
    1. Open the file in binary mode.

    2. The read-modify-write operation on the...
  7. Replies
    2
    Views
    136

    > and confirm // you have properly opened...

    > and confirm // you have properly opened the file.
    You don't do this step.



    while ((fscanf(input, "%s%s%s%d%lf",
    &inventory[size].make,...
  8. 2022 and still using gets() - Ugh!!!! gets has...

    2022 and still using gets() - Ugh!!!!

    gets has been dead for a decade.
    gets, gets_s - cppreference.com

    What are you expecting to see?


    $ ./a.out
    Items will be initiated in the same...
  9. Replies
    5
    Views
    161

    $ ./a.out 0 1 2 3 4 5 6 7 8 ...

    $ ./a.out
    0 1 2 3 4 5 6 7 8
    +---+---+---+---+---+---+---+---+
    | | | | | | | | | 0
    +---+---+---+---+---+---+---+---+
    |L12| |L11| |L10| |L9 | | 1...
  10. Replies
    5
    Views
    161

    > Thank you for that, i have updated the code....

    > Thank you for that, i have updated the code. please check for the corrections needed.
    Your loops are still wrong.

    All of them should be
    for ( i = 0 ; i < 8 ; i++ )
    or
    for ( j = 0 ; j < 8 ;...
  11. Replies
    5
    Views
    161

    > for(i = 1; i

    > for(i = 1; i <9; i++)
    Array subscripts start at 0, not 1
    So you're wandering off the ends of the board array.

    You can avoid all the if/else to determine the field width by just doing this.

    ...
  12. There are a few ways you could go. ...

    There are a few ways you could go.



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

    // All the values are the same type
  13. Replies
    3
    Views
    236

    The only answer is to rebuild your library with...

    The only answer is to rebuild your library with the DAC_HandleTypeDef #define enabled.

    Or the library is always built with all the options enabled, and you just have to accept that a few pointers...
  14. Without all the createfile complication, which...

    Without all the createfile complication, which doesn't seem to add any value...

    This goes in main


    fstream new_file.open("sorted_numbers.dat", ios::out);
    for (i = 0; i <...
  15. void createFile(){ fstream new_file; ...

    void createFile(){
    fstream new_file;
    new_file.open("sorted_numbers.dat", ios::out);
    new_file << "TESTING \n\n";//just testing to see if it works. It does.
    if (!new_file) {
    ...
  16. Replies
    15
    Views
    686

    You first call getchar() and expect that it's a...

    You first call getchar() and expect that it's a '('
    Then you call rel_expr to handle the relational expression.
    Then you call getchar() and expect that it's a ')'
  17. Replies
    15
    Views
    686

    TBH, you need to define the grammar before you...

    TBH, you need to define the grammar before you write the code.

    I mean it might work for your examples at the moment, but something like
    ((((((a>b))))))
    is going to blow it up.

    compiler...
  18. Replies
    15
    Views
    686

    > I think I a have an idea but I want some help...

    > I think I a have an idea but I want some help from someone with more experience
    We await your attempt.
  19. Replies
    15
    Views
    686

    > (a>b)&(2

    > (a>b)&(2<3)The statement is false.
    Do a and b have values, in the usual sense of a variable name has a value.
    In which case, the truth value depends on those values.

    > I have an assignament...
  20. 1. It seems like a good way for hackers to run a...

    1. It seems like a good way for hackers to run a DoS attack on your site by dumping everyone's accounts into a 24 hour purgatory.
    Good luck with that tech support storm.

    2. Your reject rules leak...
  21. Replies
    2
    Views
    212

    Which OS and compiler are you using? I'd guess...

    Which OS and compiler are you using?

    I'd guess Windows, since you mentioned COM1

    CreateFileA function (fileapi.h) - Win32 apps | Microsoft Learn
    Scroll a long way down to "Communications...
  22. Replies
    8
    Views
    350

    void Test(int idx) { uint8_t val1, val2; ...

    void Test(int idx)
    {
    uint8_t val1, val2;

    GetArgumentFromString (functions[idx].arguments[0], &val1); //arguments[0] = "var1"
    GetArgumentFromString...
  23. What exactly are you trying to sum? The whole...

    What exactly are you trying to sum?

    The whole array?
    The first row?
    The first column?

    > int num =(sizeof(b)/sizeof(b[0]));
    This is only going to tell you how many rows your array has (ie, 4)...
  24. I suppose the first question is whether you're...

    I suppose the first question is whether you're learning C or C++.

    You posted on the C++ forum, and your fuzzy filename is a .cpp file.

    But the code is pure C.



    Your inner loop to check...
  25. Thread: Encrypt a number

    by Salem
    Replies
    10
    Views
    386

    > This is how I solved it. I am not sure if this...

    > This is how I solved it. I am not sure if this is how it was supposed to be done.
    Given the information you have, it's fine.

    The final 10 lines of code can be done with one.

    ...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4