what am I missing? (Program won't compile)

This is a discussion on what am I missing? (Program won't compile) within the C Programming forums, part of the General Programming Boards category; The following program will not compile, it gives me a long line of errors: >Source 1.c 1>c:\program files (x86)\microsoft visual ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    34

    what am I missing? (Program won't compile)

    The following program will not compile, it gives me a long line of errors:
    >Source 1.c
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(39) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(39) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(41) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(41) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(41) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(41) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(41) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(41) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(42) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(42) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(42) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(42) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(42) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(42) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(43) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(43) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(43) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(43) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(43) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(43) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(44) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(44) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(44) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(44) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(44) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(44) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(45) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(45) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(45) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(45) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(45) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(45) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(46) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(46) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(46) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(46) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(46) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(46) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(47) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(47) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(47) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(47) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(47) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(47) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(48) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(48) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(48) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(48) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(48) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(48) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(49) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(49) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(49) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(49) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(50) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(50) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(50) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(50) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(51) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(51) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(51) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(51) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(51) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(51) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(52) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(52) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(52) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(52) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(52) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(52) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(53) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(53) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(53) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(53) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(53) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(53) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(54) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(54) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(54) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(54) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(54) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(54) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(55) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(55) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(55) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(55) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(55) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(55) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(56) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdio(56) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(23) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(23) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(23) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(23) : error C2059: syntax error : ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(23) : error C2143: syntax error : missing '{' before ':'
    1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(23) : fatal error C1003: error count exceeds 100; stopping compilation


    Following is my code, please help!? It may be worth noting that this program compiles just fine as a C++ program, but when I change the name of the source file from .cpp to .c it blows up. Thank you.

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string>
    #define LUNCHES 5
    #define PRESTORED_ITEMS 2
    #define BUFSIZE 30
    #define BUFFMT ""
    
    struct Food
    {
       char *name;
       int weight, calories;
    };
    
    struct Food lunch[LUNCHES] = 
    {
       { "apple", 4, 100 },
       { "salad", 2, 80 }
    };
    
    int main(void)
    {
    
       int itemCounter;
       int resultcounter;
       
       for(itemCounter = PRESTORED_ITEMS; itemCounter < LUNCHES; itemCounter++)
       {
          size_t length;
          char buf[BUFSIZE];
    
          printf( "Enter:   food  weight  calories     ");
          scanf(BUFFMT "%s %i %i", buf, &lunch[itemCounter].weight, &lunch[itemCounter].calories);
          length = strlen(buf) + 1;
    
          if ((lunch[itemCounter].name = (char *)malloc(length)) == NULL)
          {
             fprintf(stderr, "malloc out of memory\n");
             exit(EXIT_FAILURE);
          }
          memcpy(lunch[itemCounter].name, buf, length);
       }
    
       printf("\nTodays Lunch menu: \n\n");
       for(resultcounter = 0; resultcounter < (LUNCHES); resultcounter++)
          printf("%s %d %d\n",lunch[resultcounter].name, lunch[resultcounter].weight, lunch[resultcounter].calories);
       printf("\n");
    
       return(EXIT_SUCCESS);
    
    }

  2. #2
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    Should be #include <string.h>

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    34

    Thank you

    Duh! Thanks.

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,596
    SourceForge.net: Scanf woes - cpwiki
    Also, don't forget that casting the return of malloc is unnecessary and potentially dangerous (see site faq).
    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. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 02:30 PM
  2. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  3. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 02:49 PM
  4. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  5. C program compile but not doing the calculations
    By abs.emailverify in forum C Programming
    Replies: 8
    Last Post: 11-08-2006, 07:43 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21