Search:

Type: Posts; User: Salem

Page 1 of 20 1 2 3 4

Search: Search took 0.33 seconds; generated 16 minute(s) ago.

  1. It's returning int, so it's 20.

    It's returning int, so it's 20.
  2. Maybe this instead. return *p;

    Maybe this instead.

    return *p;
  3. Replies
    43
    Views
    643

    You start with this. int main() { int...

    You start with this.


    int main() {
    int lotto[49] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
    13, 14,15, 16, 17, 18, 19, 20, 21,22, 23, 24, 25,
    26,...
  4. > Line number 10 calls function next , but how...

    > Line number 10 calls function next , but how come value getting changed in bags arrary.
    Because
    a) you returned a pointer
    b) you dereferenced that pointer
    c) you have an assignment.

    Line 10...
  5. Replies
    1
    Views
    69

    Better variable names to start with. This...

    Better variable names to start with.

    This prints information about the structure of the shape you want


    for ( row = 0, items_on_row = 4 ; row < 3 ; row++, items_on_row-- ) {
    printf("Row %d...
  6. Replies
    43
    Views
    643

    First, you said > I want to create a program...

    First, you said
    > I want to create a program which generates 6 numbers from a range of 1 to 49.

    > Ok,but how is that going to help me input 6 numbers and check if the input I gave is right or...
  7. Seriously, compile with warnings and fix them...

    Seriously, compile with warnings and fix them before running code.


    $ gcc -Wall foo.c
    foo.c: In function ‘main’:
    foo.c:63:15: warning: format ‘%d’ expects argument of type ‘int *’, but argument...
  8. Replies
    43
    Views
    643

    Well next, let's introduce you to the idea of a...

    Well next, let's introduce you to the idea of a shuffle.



    // pick two random lotto number positions
    int p1 = rand() % 49;
    int p2 = rand() % 49;
    // now swap them over
    int temp = lotto[p1];...
  9. Replies
    5
    Views
    188

    Having a function called 'get' which returns...

    Having a function called 'get' which returns nothing is just weird.

    And just pushing the infinite recursion out of main doesn't really make much progress.



    #include <stdlib.h>

    void...
  10. Replies
    43
    Views
    643

    > printf("%d",lotto[i]); So change the format...

    > printf("%d",lotto[i]);
    So change the format string

    printf("%d ",lotto[i]);
    or
    printf("%d, ",lotto[i]);
    or
    printf("%d\n",lotto[i]);
    or
    printf("= %d\n",lotto[i]);
  11. Replies
    4
    Views
    155

    > combination(a,start+1, 3); Perhaps...

    > combination(a,start+1, 3);
    Perhaps
    combination(a,start+1, com-1);

    The whole point of a recursive function is that you call yourself with a simpler version of the problem.
    Which in this case,...
  12. Replies
    43
    Views
    643

    > The code is indeed complicated but since this...

    > The code is indeed complicated but since this is the only thing I found...
    So it looks like wolly isn't interested in learning after all.
    Just another drive-by looking for easy google answers.
    ...
  13. Replies
    43
    Views
    643

    int numbers[49]; for ( int = 0 ; i < 49 ; i++ )...

    int numbers[49];
    for ( int = 0 ; i < 49 ; i++ ) numbers[i] = i+1;


    vs this, which wastes element 0 of the array.


    int numbers[50];
    for ( int = 1 ; i <= 49 ; i++ ) numbers[i] = i;
  14. Replies
    43
    Views
    643

    Right, first issue is that arrays start at...

    Right, first issue is that arrays start at subscript 0.

    So either make your array 50 elements long, or your loop
    for ( i = 0 ; i < 49 ; i++ )


    Then I asked you to print the array.
    Which...
  15. Replies
    43
    Views
    643

    Well if you've never written any code, then all...

    Well if you've never written any code, then all the exuberance shown by the regulars probably isn't what you want.

    Here's an exercise for you.
    - create an array of 49 elements, and use a loop to...
  16. Well your first problem is that you have a main()...

    Well your first problem is that you have a main() which is poorly formatted, 100's of lines long AND riddled with goto's.
    Whoever's been responsible for your programming education up to now has been...
  17. Replies
    8
    Views
    183

    Hodor means that if you include that .h file in...

    Hodor means that if you include that .h file in more than one place, you end up with multiply defined symbols.
    Whilst technically correct for a single source file example, it's an awful example to...
  18. The standard library header files such as...

    The standard library header files such as stdio.h, string.h, stdlib.h etc are all resolved by libc, and the compiler automatically uses that.

    Historically, the math library was separate because...
  19. Thread: 3-D arrays

    by Salem
    Replies
    5
    Views
    110

    Right, so you've got 2D arrays figured out. A...

    Right, so you've got 2D arrays figured out.

    A 3D array would be something like


    int marks[YEARS][COURSES][STUDENTS];
  20. Replies
    10
    Views
    133

    command gcc -Wall -Wextra -o test test.c would...

    command gcc -Wall -Wextra -o test test.c
    would be a good place to start.


    command gcc --version
    would tell us just how old your compiler is.
  21. Thread: 3-D arrays

    by Salem
    Replies
    5
    Views
    110

    > 5 stdudents is stuying in fisrt standard Whose...

    > 5 stdudents is stuying in fisrt standard Whose marks are as follows 40, 65, 98, 47, 65.
    > 8 stdudents is stuying in second standard Whose marks are as follows 58, 23, 40, 80, 65, 98, 47, 65.
    > 10...
  22. Replies
    10
    Views
    133

    > The program is not working as it should...

    > The program is not working as it should supposed to do


    $ cat foo.c
    #include<stdio.h>
    void Fun (int content[], int n );

    int main ()
    {
    int n = 6;
  23. Replies
    1
    Views
    125

    Study what miles / 500 and miles % 500 tell you.

    Study what miles / 500 and miles % 500 tell you.
  24. Replies
    15
    Views
    256

    Also here -> Cout of unsigned char - C++ Forum...

    Also here -> Cout of unsigned char - C++ Forum

    You could try say


    ofstream of("output.txt");
    of << "12" << (unsigned char)(133) << "34" << '\n';

    and verify using a hex editor whether the...
  25. Replies
    15
    Views
    445

    Which Compiler are you using? curl - Download...

    Which Compiler are you using?
    curl - Download
    There are pre-compiled binary packages which you just install/extract, then point the compiler to.
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4