标签: syntax-error

跟随C代码编译错误的原因

?#include? <stdio.h>

void main(void)
{
    char cValue='a';
    int iValue=1234567;
    long 1Value=7890123;
    float fValue=3.141592;
    double dValue=3.141592;
    char*string="korea";
    char buffer[100];

    sprintf(buffer,"char type is %c", cValue);
    puts(buffer);

    sprintf(buffer,"int type is %d", iValue);
    puts(buffer);

    sprintf(buffer,"long type is %1d", 1Value);
    puts(buffer);

    sprintf(buffer,"float type is %f", fValue);
    puts(buffer);

    sprintf(buffer,"double type is %e", dValue);
    puts(buffer);

    sprintf(buffer,"char* type is %s", string);
    puts(buffer);
}
Run Code Online (Sandbox Code Playgroud)

当我使用此代码编译时,出现语法和其他错误.

这段代码有什么问题?

错误消息:

76\76.c(7) : error C2059: syntax error : 'bad suffix on number'
76\76.c(7) : error C2143: syntax error : missing ';' before 'constant' …
Run Code Online (Sandbox Code Playgroud)

c compilation syntax-error

-5
推荐指数
1
解决办法
852
查看次数

编译C程序时"{\ rtf1\ansi"出错

#include <stdio.h>

main()
{
    float fahr, celsius;
    int lower, upper, step;

    lower = 0;
    upper = 300;
    step = 20;

    fahr = lower;

    while (fahr <= upper) {
        celsius =(5.0/9.0)*(fahr-32.0);
        printf( “%3.0f %6.1f\n”,fahr,celsius );
        fahr = fahr + step;
    }
}
Run Code Online (Sandbox Code Playgroud)

我正在使用mac.在终端中,我用gcc -g file.c编译并获得以下错误和警告:

file.c:1:1: error: expected identifier or '('
{\rtf1\ansi\ansicpg1252\cocoartf1265\cocoasubrtf190
^
file.c:21:11: warning: missing terminating ' character [-Winvalid-pp-token]
        printf( \'93%3.0f %6.1f\\n\'94,fahr,celsius );\
                 ^
Run Code Online (Sandbox Code Playgroud)

我直接从"C编程语言"中取出了代码.为什么不工作?另外,我使用文本编辑器创建了文本文件.但是,每当我对其进行更改并保存时,它都会恢复为.rtf.我该如何解决这个问题?

c syntax-error

-5
推荐指数
1
解决办法
4328
查看次数

为什么我在While循环中不断出现"预期表达式错误"?

所以我正在尝试将代码放在一起用于我的作业分配,并且出于某种原因,我在我的while循环条件下不断得到预期的表达式错误,我将<= end_money部分放在一起.错误显示在<=上.这是我的代码中唯一一个我收到此错误的地方.如果有人能帮助我,我会非常感激.我被困了这么久.这是片段:编辑:还有一个while循环的结束括号,我只是忘了将它粘贴在这里.

int player_total = 0;
int dealer_total = 0;
int player_bet;
int card_value = 0;
const int end_money = 1000;
const int starting_money = 100;
string card;
string response;



while (player_bet >= 0 && <= end_money)
{

    cout << "You have $100. Enter bet: ";
    cin >> player_bet;

    if (player_bet <= starting_money) {
        return true;

    }

    else if (player_bet > starting_money) {
        cout << "You only have $100 to bet. Enter bet: ";
    }
Run Code Online (Sandbox Code Playgroud)

c++ loops syntax-error while-loop visual-studio

-5
推荐指数
1
解决办法
325
查看次数

我无法解决的T_CONSTANT_ENCAPSED_STRING错误

这段代码:

    $current_user = get_currentuseinfo();
foreach ($alleds as $ed) {
    $checked = (in_array($ed->ID,(array)$currenteds)) ? ' checked="checked"' : '';
    $disabled = (!current_user_can('administrator') && $current_user->ID !== $ed->ID) ? ' disabled="disabled" : '';
    echo '<input type="checkbox" name="currenteds[]" value="' . $ed->ID . '"' .$checked . '" '.$disabled.' /><label for="ratings[]">'.$ed->user_nicename.'</label>';
}
Run Code Online (Sandbox Code Playgroud)

给我这个错误:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Run Code Online (Sandbox Code Playgroud)

现在,我一直在努力解决为什么我收到这个错误,但我无法弄明白.问题可能就echo在线上.你知道问题是什么以及我如何解决它?

php syntax-error

-6
推荐指数
1
解决办法
84
查看次数

这个常数"UNITS"的值

我复制了互联网的代码源,它有一个恒定的"UNITS".这个常数的价值是多少?我想找到但没找到.

http://graph-studio-next.googlecode.com/svn-history/r169/trunk/baseclasses/pullpin.cpp

 m_tDuration = llTotal * UNITS;
Run Code Online (Sandbox Code Playgroud)

syntax-error

-6
推荐指数
1
解决办法
123
查看次数

python for循环中的语法错误

这是我的第一个问题,但我多次访问该网站来寻找答案。我面临着一个看起来非常愚蠢的问题。我正在尝试在 python 中创建一个“2d”列表,但语法错误在逗弄我。这是我的代码:

def gen2darr(row, column):  # generates an array
    for in range row:
        arr.append([])  # create the lines
    for i in range row:
        for in range column:
            arr[i].append(float(int(row*column*random)))   
            # fills the array, float(int( because I want floats that 'are ints', 
            # ex: 2.0 or 152.0
Run Code Online (Sandbox Code Playgroud)

这是我得到的:

    for in range row:
         ^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

我尝试以这种方式在 for 循环中放入一个值:

    for j in range row:
Run Code Online (Sandbox Code Playgroud)

但我然后得到这个:

    for j in range row:
                     ^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

有人可以帮我弄这个吗?对我来说,语法错误意味着我可能在某个地方缺少括号或逗号,但我找不到它。

python for-loop syntax-error python-3.x

-6
推荐指数
1
解决办法
4万
查看次数

是否有"= +"运算符这样的东西?

我想知道为什么+=有效但=+无效.假设我有这样的代码:

string strOne = "World!";
strOne =+ "Hello ";//strOne = "Hello " + strOne; not valid
//Error: Operator '+' cannot be applied to operand of type 'string'
//Intended Output: Hello World!

string strTwo = "Hello ";
strTwo += "World!";//strTwo = strTwo + "World!"; valid
//Output: Hello World!
Run Code Online (Sandbox Code Playgroud)

我也不确定是否strOne =+ "Hello ";相同strOne = "Hello " + strOne;.是否有任何关于为什么=+无效或无法在语法上正确的规则?

c# syntax-error

-6
推荐指数
1
解决办法
2090
查看次数

否则没有错误?

我想知道为什么这段代码给了我这个问题,请记住它已经在同一个项目的早期表单中工作但它拒绝在这里工作.

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt){                                         
if (jCheckBox1.isSelected()== true)
jCheckBox1.equals(56);
if (jCheckBox2.isSelected()== true)
jCheckBox2.equals(50);
if (jCheckBox3.isSelected()== true)
jCheckBox3.equals(56);
if (jCheckBox4.isSelected()== true)
jCheckBox4.equals(56);
if (jCheckBox5.isSelected()== true)
jCheckBox5.equals(56);
if (jCheckBox6.isSelected()== true)
jCheckBox6.equals(56);
new Form6().setVisible(true); 

else
if (jCheckBox1.isSelected()== false)
jCheckBox1.equals(0);
if (jCheckBox2.isSelected()== false)
jCheckBox2.equals(0);
if (jCheckBox3.isSelected()== false)
jCheckBox3.equals(0);
if (jCheckBox4.isSelected()== false)
jCheckBox4.equals(0);
if (jCheckBox5.isSelected()== false)
jCheckBox5.equals(0);
if (jCheckBox6.isSelected()== false)
jCheckBox6.equals(0);

JOptionPane.showMessageDialog(this, "Please Choose An Option and Try Again");
Run Code Online (Sandbox Code Playgroud)

如果我有办法jCheckBox用不同的方法计算价值,那么我非常渴望学习.我的教授说,他几乎了解了所有关于java netbeans和东西的东西,但到目前为止,他并没有多大的帮助.

java swing syntax-error jcheckbox

-7
推荐指数
1
解决办法
288
查看次数

为什么表达式'a ++ + = b'会出错?

#include <iostream.h>
int main()
{
  int a = 2;
  int b = 3;
  a++ += b;
  std::cout << a;
}
Run Code Online (Sandbox Code Playgroud)

我对此的理解是,这个表达式首先评估a + b,将该值存储在a中然后递增它.这里发生了什么?

c++ compiler-errors syntax-error

-8
推荐指数
1
解决办法
131
查看次数

这个C++代码不起作用.有人可以帮帮我吗?

目的:获得输出"(212)767-8900"

#include <iostream.h>
#include <conio.h>
using namespace std;
struct Phone
{
   int area;
   int exc;
   int num;
};
void echoer(Phone);

int main()
{
Phone no1, no2;
 no1.area = 212, no1.exc = 767, no1.num = 8900;

void echoer(Phone no)
{
    cout << '(' << no.area << ') ' << no.exc << '-' << no.num;
}
echoer(no1);

getch();
}
Run Code Online (Sandbox Code Playgroud)

c++ syntax-error

-11
推荐指数
1
解决办法
104
查看次数