CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    41
    Thanks I fixed the problem the reason I am using c instead of c++ is because my lecture is living in the dark ages (ones and zeros)
    Last edited by Robbo99; October 21st, 2004 at 06:51 AM.

  2. #2
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: printing the contents of a pointer

    Quote Originally Posted by Robbo99
    but instead it is giving me large numbers which I think are the pointer address but not the output here is the code I would love it if someone could show me how to fix it
    ah the joys of scanf how are you entering the data all in one line then note that scanf will read the entire line into you char array which only holds 10 characters and hence produce a buffer overflow overwriting anything in memory after that buffer is there any reason why you are using plain old C instead of C++

  3. #3
    Join Date
    Apr 2004
    Location
    In the back seat of New Horizons.
    Posts
    1,238

    Re: printing the contents of a pointer

    When the problem lies with scanf, use strncpy. That way, you can specify just how much you would like to copy into the character array.
    Here are the rules, you must obey them or the gender bender will get you.

    And if you ever think of posting without code-tags, the evil monkey will come after you.

  4. #4
    Join Date
    Feb 2002
    Posts
    4,640

    Re: printing the contents of a pointer

    Robbo99 - Please don't delete your original question. Even though it was answered to your satisfaction, some of us (namely me) would like to know what the problem was...

    Thanks!

    Viggy

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured