Thread: Trying to create a simple array program

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    buffer is only 10 chars long; you are trying to copy 1000 chars from it. This results in undefined behavior.

    Edit: And, the line below; write a zero byte beyond the end of the storage since i = 1000 is past the end.
    Code:
    storage[i] = '\0';
    Hint: Lookup fgets and strcpy functions.
    This problem is likely designed to use fgets() and might be designed to use one of the str... functions.

    Tim S.
    Last edited by stahta01; 09-16-2017 at 12:19 AM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 22
    Last Post: 09-03-2013, 12:20 PM
  2. create a simple program using linked list
    By tillu in forum C++ Programming
    Replies: 1
    Last Post: 08-31-2011, 12:53 AM
  3. Simple Array Program
    By Chemeng11 in forum C++ Programming
    Replies: 6
    Last Post: 05-02-2011, 08:09 PM
  4. create and populate create bidimensional array
    By darkducke in forum C Programming
    Replies: 0
    Last Post: 12-03-2010, 07:06 AM
  5. create a dll for C++ simple program and call from VB
    By motiz in forum C++ Programming
    Replies: 1
    Last Post: 01-09-2008, 04:54 AM

Tags for this Thread