Thread: pointer arrays

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    12

    pointer arrays

    I'm not sure if I'm understanding this properly, i have the following in c++

    Code:
    void test1(byte* dcData,int x,int y)
    {
       int startrow=0;
       int endrow=2;
       byte* data = dcData;
       byte* adjusteddata=data+startrow*x+startcol*y;
       for(int y=0;y<whatever;y++)
       {
          byte* dest=adjusteddata+x*y;
       }
    }
    I've done a conversion to c# but i think I may be interpreting it wrong??

    Code:
    public void test1(byte[] dcData,int x,int y)
    {
       int startrow=0;
       int endrow=2;
       byte[] data = dcData;
       byte[] adjusteddata=data+startrow*x+startcol*y;
       for(int y=0;y<whatever;y++)
       {
          byte[] dest=adjusteddata+x*y;
       } 
    }

  2. #2
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Seems like more of a C# forum question.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  3. #3
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    367
    If you are changing it to c# method, then you will need to declare as unsafe, which basically means you code maybe executed depending upon the users machine you are running it on. If you start using c style types, then your code becomes less portable; which works against the .net framework. Its still a pile of toss anyway (well its ok i suppose), c++ will always live!
    Be a leader and not a follower.

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    I suppose if you describe what you want to do, I could show you a way to implement it properly in C#. However, the piece you have given doesn't do anything usefull and I won't take guesses what it should do.

    Give a clear description what you want the function to do and what parameters you want to give and we'll find a nice implementation.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  5. #5
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    I think PaulStat just wants to know if the second piece of code does the same thing in C# that the first code does in C++. I don't think he wants an optimization or anything.

    Shouldn't this sort of thing be in a documentation somewhere, or a tutorial?
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 04-04-2009, 03:45 AM
  2. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  3. pointer arrays!!!
    By condorx in forum C Programming
    Replies: 1
    Last Post: 05-14-2002, 08:55 AM
  4. pointer arrays
    By condorx in forum C Programming
    Replies: 3
    Last Post: 05-03-2002, 09:04 PM
  5. Replies: 4
    Last Post: 11-05-2001, 02:35 PM