Results 1 to 7 of 7
  1. #1

    Posts
    40

    Question (C Code)

    Hey there,

    I was wondering if you could help me out on this, I'm stuck don't know what to do. I am making a code where there's a fuction that returns the values +1 in case a number appears. Here's a small code I made on another one to not post so much code and this isn't working.

    -------

    #include <stdlib.h>
    #include <stdio.h>
    #include <conio.h>


    int add(int b,int r,int p,int i,int h,int l,int c1,int c2,int c3,int d1,int d2,int d3)
    {

    //cores
    b++;
    r++;
    //parimpar
    p++;
    i++;
    //altobaixo
    h++;
    l++;
    //coluna 1 2 3
    c1++;
    c2++;
    c3++;
    //duzia 1 2 3
    d1++;
    d2++;
    d3++;
    return b , r , p , i , h , l , c1 , c2 , c3 , d1 , d2 , d3;
    }

    int main()

    {

    int num;
    int black=0,red=0,par,impar,high,low,col1,col2,col3,du z1,duz2,duz3;

    while(num!=99)
    {
    printf("num - ");
    scanf("%d",&num);

    switch(num)
    {
    case 0:
    add(black,red,par,impar,high,low,col1,col2,col3,du z1,duz2,duz3);
    break;
    }
    printf("Preto = %d",black);
    }

    getch();
    }

    -----

    Hope someone can help me out, thanks!

  2. #2
    Bot Coder
    flashbang is offline

    Posts
    584
    Mind telling us what the error is?

    //siggy by Poseidon

  3. #3

    Posts
    40
    int add(int b,int r,int p,int i,int h,int l,int c1,int c2,int c3,int d1,int d2,int d3)
    {

    //cores
    b++;
    r++;
    //parimpar
    p++;
    i++;
    //altobaixo
    h++;
    l++;
    //coluna 1 2 3
    c1++;
    c2++;
    c3++;
    //duzia 1 2 3
    d1++;
    d2++;
    d3++;
    return b , r , p , i , h , l , c1 , c2 , c3 , d1 , d2 , d3;
    }


    --


    the error was that but I've fixed it already, it works using pointers.

  4. #4
    Bot Coder
    flashbang is offline

    Posts
    584
    Quote Originally Posted by HowInteresting View Post
    int add(int b,int r,int p,int i,int h,int l,int c1,int c2,int c3,int d1,int d2,int d3)
    {

    //cores
    b++;
    r++;
    //parimpar
    p++;
    i++;
    //altobaixo
    h++;
    l++;
    //coluna 1 2 3
    c1++;
    c2++;
    c3++;
    //duzia 1 2 3
    d1++;
    d2++;
    d3++;
    return b , r , p , i , h , l , c1 , c2 , c3 , d1 , d2 , d3;
    }


    --


    the error was that but I've fixed it already, it works using pointers.
    I don't see any error message there but if you have it fixed it's good!

    //siggy by Poseidon

  5. #5

    Posts
    40
    There were local stacks, so I used pointers to use the address of the variable, simple

  6. #6
    Developer
    notion75 is offline

    Posts
    241
    It hurts looking at that code.

  7. #7

    Posts
    40
    Sorry if I'm still new to this but I use pointers now and I just made it into 1 void, so its like this:

    void inc_vari(int * i)
    {
    (*i)++;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •