Search:

Type: Posts; User: Salem

Page 1 of 20 1 2 3 4

Search: Search took 0.24 seconds.

  1. Replies
    9
    Views
    113

    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
  2. Replies
    9
    Views
    113

    > 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...
  3. Replies
    9
    Views
    113

    >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...
  4. Replies
    9
    Views
    113

    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...
  5. Replies
    2
    Views
    109

    > 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,...
  6. 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...
  7. Replies
    5
    Views
    132

    $ ./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...
  8. Replies
    5
    Views
    132

    > 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 ;...
  9. Replies
    5
    Views
    132

    > 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.

    ...
  10. 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
  11. Replies
    3
    Views
    203

    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...
  12. 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 <...
  13. 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) {
    ...
  14. Replies
    15
    Views
    641

    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 ')'
  15. Replies
    15
    Views
    641

    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...
  16. Replies
    15
    Views
    641

    > 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.
  17. Replies
    15
    Views
    641

    > (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...
  18. 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...
  19. Replies
    2
    Views
    198

    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...
  20. Replies
    8
    Views
    329

    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...
  21. 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)...
  22. 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...
  23. Thread: Encrypt a number

    by Salem
    Replies
    10
    Views
    372

    > 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.

    ...
  24. > int *last = &a[n-1]; Make this const int...

    > int *last = &a[n-1];
    Make this
    const int *last = &a[n-1];

    > while(a<=last)
    This should be <, not <=

    > second_largest=*largest;
    > largest=*a;
    You want to update...
  25. Replies
    4
    Views
    205

    Compile with lots of warnings enabled. $ gcc...

    Compile with lots of warnings enabled.


    $ gcc -Wall -Wextra foo.c
    foo.c: In function ‘main’:
    foo.c:4:14: warning: statement with no effect [-Wunused-value]
    4 | int a = 1;2;3;
    | ...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4