Thread: Save values in a function

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    15

    Save values in a function

    It's supposed to generate binary numbers like this :
    00 01 10 11 000 001 010 011 ....

    And count how many times they appear in sir[].

    At the end of function Suma, I have the binary sequence in v[] and the number in nr.
    I'm using indice to copy them into secv[][] (the binary sequence) and *apar (how many times it appears in sir[]).

    However, indice resets every time I call Memorare().

    Is there any other way to do this?

    Edit:
    Removed the code.
    I managed to fix it on my own, thanks to everyone who's trying to help!
    Last edited by dgs012; 12-08-2010 at 02:32 PM. Reason: problem solved

  2. #2
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    >>However, indice resets every time I call Memorare().
    I don't get it.

  3. #3
    Registered User
    Join Date
    Nov 2010
    Posts
    15
    Quote Originally Posted by Bayint Naung View Post
    >>However, indice resets every time I call Memorare().
    I don't get it.
    First time I call Memorare() in main, for i = 2, it does this:
    Creates 00, 01, 10, 11. Indice will be 0, 1, 2, 3.

    When i = 3, it creates 000, 001, 010, 011, 100, 101, 110, 111.
    But indice goes 0, 1, 2, 3, 4, 5, 6, 7, instead of 4, 5, 6, 7, 8, 9, 10, 11.

  4. #4
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    hum?
    Are you trying to do something like this:
    Code:
    void change_it(int a)
    {
        a = 4; 
    }
    
    ....
    int n = 10;
    change_it(n);
    // still 10 coz n is pass by value
    
    void change_it(int *a)
    {
       *a = 4;
    }
    
    ...
    int n = 10;
    change_it(&n);
    // now n is 4

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling C in Visual Studio 2005
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-16-2009, 04:25 AM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. Parameter pass
    By Gades in forum C Programming
    Replies: 28
    Last Post: 11-20-2001, 02:08 PM