Thread: stdafx.h and const char* error

  1. #1
    Registered User
    Join Date
    Jun 2012
    Posts
    1

    stdafx.h and const char* error

    I was creating a C program for creating Windows Socket, using Visual Studio 2010. I got the following errors while trying to compile it:

    1. error C1083: Cannot open include file: 'stdafx.h': No such file or directory [For the line, #include <stdafx.h>]

    2. IntelliSense: cannot open source file "stdafx.h" [For the line, #include <stdafx.h>]

    3. IntelliSense: a value of type "const char *" cannot be assigned to an entity of type "char" [For the line, buf[0] = " ";]

    How to fix those problems, I tried google and solved other 4 errors but these three are being headache for me, I have just started Win32 Application in C so I don't have deep knowledge. I am waiting for your help.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > #include <stdafx.h>
    Delete this line from your source file.

    Then navigate to something like project -> settings -> compiler -> pre-processor
    You're looking for a setting called "precompiled headers"
    When you find it, turn it OFF for both debug and release builds, then rebuild everything.
    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.

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I don't recommend Visual Studio for C programming, though. It lacks C90 support.
    GCC is an excellent compiler for C90. Code::Blocks can be used as an IDE for the compiler.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 04-20-2011, 01:19 PM
  2. Replies: 3
    Last Post: 11-15-2009, 04:57 AM
  3. Replies: 7
    Last Post: 04-28-2008, 09:20 AM
  4. Replies: 9
    Last Post: 07-07-2006, 11:03 AM
  5. Const Char to Char Error
    By stickman in forum C++ Programming
    Replies: 36
    Last Post: 08-29-2004, 01:07 PM

Tags for this Thread