How come argv can be incremented?

This is a discussion on How come argv can be incremented? within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by Elysia I don't know if I agree. Pointers are still very important, even in C++. It's absolutely ...

  1. #16
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by Elysia View Post
    I don't know if I agree. Pointers are still very important, even in C++.
    It's absolutely a good thing to know about pointer basics. My own guess is that books don't cover the basics of pointers (they merely say, if you want another function to modify an argument, then do this - it's called pass by pointer) or they simply do not understand it and skips the basics.
    Or it could be the teachers' fault. We know how many bad teachers are out there.
    Then I think you need to really ditch the virtual memory attachment if you want to really nail the basics.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  2. #17
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839
    i have been thinking about the subtleties in this and i made this little test project that i think helped me understand the differences here

    Code:
    void __fastcall func(char *a[])
    {
    }
    
    int main()
    {
            char *a[4]={"s0","s1","s2","s3"};
            char **a0 = &a[0];
            func(a);
            return 0;
    }
    stepping through the code with the debugger shows that a0 in main is equal to a in the body of func.

    hope that is similarly somewhat useful to someone else.

  3. #18

  4. #19
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    hope that is similarly somewhat useful to someone else.
    Perhaps, but I doubt it. The issue here is one of syntax and language semantics, which are lost i the low-level execution.

    On a side note, never asign string literals to char*. Always use const char*.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #20
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,022
    Quote Originally Posted by Dave_Sinkula View Post
    Then I think you need to really ditch the virtual memory attachment if you want to really nail the basics.
    What would make you say that?
    Virtual Memory is the basics to pointers.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #21
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Not at all. Virtual memory is a mechanism for operating system to separate processes from each other and allows paging and stuff like that. It's completely irrelevant to the application's usage of pointers.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #22
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,022
    But it does explain why you get a crash when you access a non-modifiable page and the concept of addresses.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #23
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Virtual memory is the basics of more complicated OS memory management, not pointers. You could easily use pointers on a system that doesn't have virtual memory.

    edit: beaten

    no it doesn't. it could be implemented with simple range checking.

  9. #24
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,274
    Quote Originally Posted by Elysia View Post
    But it does explain why you get a crash when you access a non-modifiable page and the concept of addresses.
    Because before VM, there were no addresses? Why do you insist on continuing down flawed paths of argument?

  10. #25
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,022
    Because it makes sense to me. You access a page you don't have access to, you get a crash. Simple. That's how modern OSes works.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #26
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,274
    Quote Originally Posted by Elysia View Post
    Because it makes sense to me. You access a page you don't have access to, you get a crash. Simple. That's how modern OSes works.
    You're talking nonsense. You previous post claims that VM somehow explains the concept of addresses.

    In fact, VM makes it harder to explain addresses, by creating two different types (virtual and physical)

  12. #27
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Quote Originally Posted by Elysia View Post
    Because it makes sense to me. You access a page you don't have access to, you get a crash. Simple. That's how modern OSes works.
    There are C and C++ compilers for DOS, which does not have virtual memory. They still crash when you write to a memory location you're not supposed to. Just not as reliably.

  13. #28
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,022
    Whatever. What point is it to argue?
    Knowing VM makes it easier to understand pointers to me. Let it be that way.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  14. #29
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,274
    Quote Originally Posted by Elysia View Post
    Whatever. What point is it to argue?
    Knowing VM makes it easier to understand pointers to me. Let it be that way.
    Seeing as how you are making illogical connections between concepts which could confuse a beginner to hell and back, I feel compelled to.

  15. #30
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839
    Quote Originally Posted by CornedBee View Post
    Perhaps, but I doubt it. The issue here is one of syntax and language semantics, which are lost i the low-level execution.

    On a side note, never asign string literals to char*. Always use const char*.
    is there any difference, other than semantically, between
    Code:
    func(foo *arg) 
    {
    }
    and
    Code:
    func(foo arg[])
    {
    }
    or is that there just for the convenience of the programmer to connote that one is definitely an array?

Page 2 of 3 FirstFirst 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. argv
    By taurus in forum C Programming
    Replies: 15
    Last Post: 10-14-2007, 09:57 AM
  2. Using argc and argv data
    By Rad_Turnip in forum C Programming
    Replies: 4
    Last Post: 03-31-2006, 06:09 AM
  3. Converting a argc / argv construct into a va_list
    By chambece in forum C Programming
    Replies: 6
    Last Post: 07-03-2005, 05:47 PM
  4. how do i? re: argc - argv
    By luigi40 in forum C Programming
    Replies: 2
    Last Post: 06-11-2004, 11:17 AM
  5. more argv and argc
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 09-09-2001, 12:04 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21