Thread: Why does this malloc give me a segmentation fault?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    69
    Because normally, the user will name the file (which I'm stating as "test1.txt") as an argument. Meaning that, to run this, the use will type: /nameofprog test1.txt

    So in other words, the program can't initially be told how long the name of the input file will be. I guess I couldn't just write strlen("argv[1].titles") or something like that.
    Last edited by Xpl0ReRChR; 01-09-2012 at 10:31 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 03-12-2011, 08:28 PM
  2. Segmentation fault with Malloc
    By uniprog in forum C Programming
    Replies: 7
    Last Post: 12-02-2010, 10:22 AM
  3. malloc + segmentation fault
    By ch4 in forum C Programming
    Replies: 5
    Last Post: 04-07-2009, 03:46 PM
  4. malloc segmentation fault
    By BharathKumar in forum C Programming
    Replies: 5
    Last Post: 06-27-2007, 02:53 AM
  5. segmentation fault and memory fault
    By Unregistered in forum C Programming
    Replies: 12
    Last Post: 04-02-2002, 11:09 PM