1
// CT project.cpp : Defines the entry point for the console application.

#include "stdafx.h"

// libraries: ctype.h , iostream, conio.h, stdio.h, string.h, stdlib.h, math.h

using namespace std;

struct pgm
{
    char line[20];
} s[100];

void check(char s[])
{
    cout<<"\n";
    if(!strcmpi(s,"If"))
    {
        cout<<"keyword:If"; 
        return;
    }
    if(!strcmpi(s,"Then"))
    { 
        cout<<"keyword:Then";
        return; 
    } 
    if(!strcmpi(s,"Else")) 
    { 
        cout<<"keyword:else"; 
        return;
    }
    if(!strcmpi(s,"[END]"))
    {
        return; 
    }

    cout<<"expression:"<<s;
}

void clrscr( void )
{
    // some code here
}

void main ()
{
    char t[20];
    int i=0, j=0, k=0;

    clrscr();

    cout<<"\n\n enter the program code: (to STOP input type End) \n";

    do
    {
        gets(s[i].line);
    }
    while(strcmpi(s[i++].line,"END"));

    k=k-1;
    do
    {
        k++;
        for(i=0; s[k].line[i]!='\0'; i++, j++)
        {
           if(s[k].line[i]==' ')
           { 
               t[j]='\0';
               j=-1; 
               check(t);           
           }
           else
               t[j]=s[k].line[i];
       }
       t[j]='\0';
       j=0;
       check(t);
    }
    while(strcmpi(s[k].line,"END"));
    getchar();
}
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
  • http://stackoverflow.com/questions/10888391/error-link-fatal-error-lnk1123-failure-during-conversion-to-coff-file-inval – drescherjm Dec 11 '13 at 14:45
  • Why are there random blank lines everywhere, and horrible indentation? – Lightness Races in Orbit Dec 11 '13 at 14:55
  • Welcome to Stack Overflow. Please read the [About] page soon. When you format code for SO, it is usually best to prepare it outside the SO browser window, with spaces not tabs for the indentation. Then copy it into the question are, highlight it all, and use the **`{}`** button above the edit box to indent it as code. (@JoeZ: if you indent code, undo the double spacing too!) – Jonathan Leffler Dec 11 '13 at 14:56
  • Also, FYI, headers are not libraries per se; they are headers. They declare the facilities provided by a library, but they are not libraries themselves; they are headers. You do no maths; there is no need for ``. AFAICS, you don't use anything from `` or even ``. You should be using C++ headers with C++ code, in general. Since you're using `cout << ...` notation, this is not a C question really. Dual tagging with C and C++ is not popular. – Jonathan Leffler Dec 11 '13 at 15:03
  • Oh, and if the problem is a 'corrupted or invalid COFF file', the chances are that your problem is in the way you compiled (or didn't compile) the code before trying to link the program. I recommend removing the `.obj` file and running the build again. Check that the linker is being given an object file, not the source code. – Jonathan Leffler Dec 11 '13 at 15:18

0 Answers0