本机项目设置 [英] Project settings for native

查看:64
本文介绍了本机项目设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如果我将本机.C文件添加到空项目中并想要构建.lib文件,该项目将与CPP项目链接在一起,而该项目具有/clr选项以构建.exe?
但是我的本机代码给出了基本错误,例如,
它甚至没有编译此代码..

Hi,

What are projects to be made if I added a native .C file to empty project and want to build .lib file which will be linked with CPP project with /clr option to build .exe ??

But my native code is giving basic errors like,
it is not even compiling this code ..

..//

int g = 1;
g++;
....///


编译器给出错误,因为
错误C2105:"++"需要左值

///HERE是整个代码的开始


compiler is giving error as
Error C2105: ''++'' needs l-value

///HERE is whole code starts

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<ctype.h>
int ch;
char Y_N;
void EASY()
{
int colr, arr, i,j,r, b[6];
char col[]={'R','Y','BG','B','P','G'};
clrscr();
textcolor(25);
gotoxy(3,5);
cprintf("Guess the hidden codes\n");
gotoxy(3,6);
cprintf("You only have fourteen tries.\n");
showcolors();
for(i=0;i<6;i++)
{
    int r=rand()%sizeof(col);
    printf("%c ",col[r]);
}
printf("\n");
for(i=1;i<=14;i++)
{printf("\nGuess No. [%d]: ",i);
for(j=0;j<6;j++)
{scanf("%d",&b[j]);
{if(col[0]==b[0])
arr++;
else
if(col[1]==b[1])   /*What should i put in the position of col[1] and*/
col++;           /*b[1] to compare the random code that was generated*/
else               /*by the program and the characters that that was*/
if(a[0]==b[2])    /*inputted by the player of the game?*/
col++;
else
if(a[0]==b[3])
col++;
else
if(a[0]==b[4])
col++;
else
if(a[0]==b[5])
col++;}
{if(a[1]==b[1])
arr++;
else
if(a[1]==b[0])
col++;
else
if(a[1]==b[2])
col++;
else
if(a[1]==b[3])
col++;
else
if(a[1]==b[4])
col++;
else
if(a[1]==b[5])
col++;}
{if(a[2]==b[2])
arr++;
else
if(a[2]==b[0])
col++;
else
if(a[2]==b[1])
col++;
else
if(a[2]==b[3])
col++;
else
if(a[2]==b[4])
col++;
else
if(a[2]==b[5])
col++;}
{if(a[3]==b[3])
arr++;
else
if(a[3]==b[0])
col++;
else
if(a[3]==b[1])
col++;
else
if(a[3]==b[2])
col++;
else
if(a[3]==b[4])
col++;
else
if(a[3]==b[5])
col++;}
{if(a[4]==b[4])
arr++;
else
if(a[4]==b[0])
col++;
else
if(a[4]==b[1])
col++;
else
if(a[4]==b[2])
col++;
else
if(a[4]==b[3])
col++;
else
if(a[4]==b[5])
col++;}
{if(a[5]==b[5])
arr++;
else
if(a[5]==b[0])
col++;
else
if(a[5]==b[1])
col++;
else
if(a[5]==b[2])
col++;
else
if(a[5]==b[3])
col++;
else
if(a[5]==b[4])
col++;}
gotoxy(60,11);
printf("Arrangements: %d\tColors: %d",arr,col);
{if(arr==6)
i=15;
printf("You have decoded the code. Congratulations!");}
}}
}
showcolors()
{
    gotoxy(3,8);
    printf("Colors are:  ");
    gotoxy(3,9);
    textcolor(RED);
    cprintf("[R]Red");
    gotoxy(11,9);
    textcolor(3);
    cprintf("[BG]BlueGreen");
    gotoxy(26,9);
    textcolor(YELLOW);
    cprintf("[Y]Yellow");
    gotoxy(37,9);
    textcolor(GREEN);
    cprintf("[G]Green");
    gotoxy(47,9);
    textcolor(9);
    cprintf("[B]Blue");
    gotoxy(56,9);
    textcolor(5);
    cprintf("[P]Purple");
    printf("\n");
}
main()
{
clrscr();
printf("MASTERMIND GAME\n\n");
printf("Choose Difficulty\n[1] EASY\n[2] NORMAL\n[3] HARD\n\n");
printf("Your Choice: ");
scanf("%d",&ch);
if(ch==1)
EASY();
else
if(ch==2)
printf("*");
else
if(ch==3)
printf("*");
else
printf("\nWRONG KEY!");
getch();
}



////---------------------- C代码结束


请帮忙!!!!!



////---------------------- C code ends


Please help !!!!!

推荐答案

..//
int g = 1;
g++;....///

此代码无法编译?可能是因为只有几个原因:

This code not compiling? It can be because of only few reasons:

  1. g是#define d作为宏!
  2. g实际上被声明为const
  3. g在类中,而方法是const
  1. g is #defined as a macro!
  2. g is actually declared to be const
  3. g is in a class, and the method is const



仅供参考,.C文件无法使用/clr进行编译.



And FYI, a .C file cannot be compiled with /clr.


这篇关于本机项目设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆