Thread: Tokenizer in C

  1. #16
    Registered User
    Join Date
    Aug 2001
    Posts
    247
    LOL Salem.

    > return 0;
    > free (ptr);
    Yeah, that'll work

    Ofcourse it wont linuxdude. The process will never reach free(ptr); as your return statement is placed before it.
    hoping to be certified (programming in c)
    here's the news - I'm officially certified.

  2. #17
    Obsessed with C chrismiceli's Avatar
    Join Date
    Jan 2003
    Posts
    501
    Linuxdude's post is excusable, he just copied Tarik's and changed it around, he mustn't have compiled it, or thought about it.
    Help populate a c/c++ help irc channel
    server: irc://irc.efnet.net
    channel: #c

  3. #18
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    I still notice that none of the attempts at calling malloc takes into account the length of the string which is intended to be copied.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #19
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    sorry abou the whole return free thing. chrismiceli is right. I just copied his code. I didn't even compile it. Well for the malloc I just guess i was lazy
    Code:
    malloc(strlen(mytext)+1));

  5. #20
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > malloc(strlen(mytext)+1));
    *Shakes head*
    +1 point for remembering the +1
    -1 point for not counting ()
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #21
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    __ whoops

  7. #22
    Registered User
    Join Date
    Aug 2004
    Posts
    8
    Thank you guys I am so appreciate with your help and I learn some important points too.
    Thank you...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Scanner? Lexical analyzer? Tokenizer?
    By audinue in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 12-23-2008, 11:32 PM
  2. string tokenizer
    By mbooka in forum C Programming
    Replies: 4
    Last Post: 02-15-2006, 06:00 PM
  3. C++ String Tokenizer
    By Annorax in forum Game Programming
    Replies: 10
    Last Post: 07-13-2005, 10:41 AM
  4. Tokenizer
    By PJYelton in forum C++ Programming
    Replies: 2
    Last Post: 01-29-2003, 03:01 PM
  5. deriving ifstream class for tokenizer
    By djh000 in forum C++ Programming
    Replies: 0
    Last Post: 09-23-2001, 02:37 AM