Thread: multi-character character constant error

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129

    multi-character character constant error

    I'm baffled, can anybody tell me why this is giving an error?
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
    FILE*in, *out;
    int ix, c;
    
    in = fopen("fg","rt");
    out = fopen("og","wt");
    
    
    
    /*read four lines of header*/
     for( ix = 0; ix < 4; ++ix ) {
      while( (c = fgetc( in)) != '/n' ) {
       fputc( c, out ) ;
      }
     }
    
    
    return 0;
    }
    Code:
    C:\>gcc t.c -Wall -Werror -ansi -pedantic
    t.c:16:30: multi-character character constant
    
    C:\>

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Code:
    while( (c = fgetc( in)) != '/n' )
    What char is that again?

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    You should also probably be calling fclose() on those files. It's not really required (since the program exits immediately afterwards), but it's good programming style.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Quote Originally Posted by MacGyver View Post
    Code:
    while( (c = fgetc( in)) != '/n' )
    What char is that again?
    Oh. D'oh! It's always something simple isn't it.

    dwks: yeah you're right I had actually copied it from another program that I'm writing. I guess I forgot to copy that part.

    thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  2. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  3. Simple vector class problem, please help
    By fidodidohk in forum C++ Programming
    Replies: 9
    Last Post: 03-30-2007, 09:13 AM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  5. UNICODE and GET_STATE
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 03:23 PM