相关疑难解决方法(0)

如何摆脱文本文件中的特殊字符?(*nix中)

我有一个源代码文件,它是从网页上的一些示例代码的副本开始的.它是在Windows下创建和编辑的,编译时没有任何问题.

但是在Mac下,我遇到了一些模糊的错误,比如:

../MyProgram.cpp:1: error: stray '\255' in program
../MyProgram.cpp:1: error: stray '\254' in program
../MyProgram.cpp:1: error: stray '#' in program
../MyProgram.cpp:3:4: error: invalid preprocessing directive #i
../MyProgram.cpp:5:4: error: invalid preprocessing directive #i
../MyProgram.cpp:7:4: error: invalid preprocessing directive #i
../MyProgram.cpp:23: error: missing terminating ' character
../MyProgram.cpp:369:6: error: invalid preprocessing directive #i
../MyProgram.cpp:371:8: error: invalid preprocessing directive #i
../MyProgram.cpp:375:8: error: invalid preprocessing directive #e
../MyProgram.cpp:381:8: error: invalid preprocessing directive #e
../MyProgram.cpp:383:6: error: invalid preprocessing directive #e
../MyProgram.cpp:385:8: error: invalid preprocessing directive #i …
Run Code Online (Sandbox Code Playgroud)

shell text gcc

1
推荐指数
1
解决办法
1543
查看次数

从默认蓝色更改标签栏图标颜色

即时通讯尝试将标签栏图标颜色从默认蓝色更改为红色...我得到此错误"Stray'\ 342'在程序中"..我得到错误" - (void)recolorItemsWithColor:....... "而且在实施部分......无论如何都要解决错误...是否还有其他方法可以将标签栏图标从默认蓝色更改为其他颜色

@interface UITabBar (ColorExtensions)

– (void)recolorItemsWithColor:(UIColor *)color shadowColor:(UIColor *)shadowColor shadowOffset:(CGSize)shadowOffset shadowBlur:(CGFloat)shadowBlur;

@end
Run Code Online (Sandbox Code Playgroud)

xcode objective-c

1
推荐指数
1
解决办法
3908
查看次数

c ++错误不能用作函数,有些杂散错误

我写了一个日历代码,但是我有一些错误.这是我的代码:

#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int month, year, Y, M;
int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int FirstDayofMonth; 

cout<<"please enter year!"<<endl;
cin>>year;
while(year<1600)
{
    cout<<"please do not enter year less than 1600!"<<endl;
    cin>>year;
}
cout<<"please enter month! (1~12)"<<endl;
cin>>month;
Y = year – (14 – month)/12;
M = month + 12 * ((14 - month) / 12) - 2;
FirstDayofMonth = (Y+Y/4-Y/100+Y/400+31*M/12+1)%7;
}
Run Code Online (Sandbox Code Playgroud)

其他部分是打印结果.它显示了下面的错误

try.cpp:18: error: stray ‘\342’ in program
try.cpp:18: error: stray ‘\200’ in program
try.cpp:18: error: stray ‘\223’ in …
Run Code Online (Sandbox Code Playgroud)

c++

1
推荐指数
1
解决办法
817
查看次数

C编译:错误:在程序中迷路'\ 4'; 八分流?

试图编译一堆.c文件

(1)文件编译正常,使用 cc

cc -Wall -Wextra -Wunreachable-code -ggdb -O0 *.c 
Run Code Online (Sandbox Code Playgroud)

(2)然后,我需要从最终输出创建一个静态库,以便在c ++程序中使用.所以我这样做:

ar cru liborientdb-c.a *.o
Run Code Online (Sandbox Code Playgroud)

(3)工作正常.但是,当我来编译包含第1行库的c ++程序testme.cpp时

(line 1 of testme.cpp)
#include "liborientdb-c.a"
Run Code Online (Sandbox Code Playgroud)

编译步骤:

cc testme.cpp
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

liborientdb-c.a:117:22: error: stray '\3' in program
liborientdb-c.a:117:263: warning: null character(s) ignored [enabled by default]
liborientdb-c.a:117:22: error: stray '\17' in program
liborientdb-c.a:117:265: warning: null character(s) ignored [enabled by default]
liborientdb-c.a:117:283: warning: null character(s) ignored [enabled by default]
liborientdb-c.a:117:22: error: stray '\22' in program
liborientdb-c.a:117:287: warning: null character(s) ignored [enabled by default]
liborientdb-c.a:117:22: error: …
Run Code Online (Sandbox Code Playgroud)

c c++ linux gcc cc

1
推荐指数
1
解决办法
1905
查看次数

C++显示奇怪的行为

我有一个简单的c ++代码,如下所示:

#include <iostream>
#include <string>
using namespace std;
int main() {
    int n , a , b ;
    cin >> n >> a >> b ;
    //This two lines are exactly same!!!!
    cout << n - max(a + 1, n - b) + 1 << endl ; 
    //cout << n?-?max(a?+?1,?n?-?b)?+?1 << endl ;
}
Run Code Online (Sandbox Code Playgroud)

在这段代码中,我有两行完全相同,但是当我编译完全相同的代码时,我得到的结果是任何输入,例如(5,2,3),但当我取消注释第二个cout并注释第一个具有所有先前条件代码无法编译(GNU 4.8.2)并得到此错误:

sample.cpp:8:5: error: stray ‘\342’ in program
     cout << n?-?max(a?+?1,?n?-?b)?+?1 << endl ;
     ^
sample.cpp:8:5: error: stray ‘\200’ in program
sample.cpp:8:5: error: …
Run Code Online (Sandbox Code Playgroud)

c++ gcc compiler-errors

1
推荐指数
1
解决办法
90
查看次数

"无效后缀"k"对整数常量"错误

我正在编写一个C程序,使用高斯算法打印给定年份的复活节日期.我是C的新手.这是代码:

#include <math.h>
int main () {
  int year = 1998;
  int a = year % 19;
  int b = year % 4;
  int c = year % 7;
  int k = floor (year/100);
  int p = floor ((13 + 8k)/25);
  int q = floor (k/4);
  int M = (15 ? p + k ? q) % 30;
  int N = (4 + k ? q) % 7;
  int d = (19a + M) % 30;
  int e = (2b …
Run Code Online (Sandbox Code Playgroud)

c

0
推荐指数
1
解决办法
3万
查看次数

程序中的 '\222'

C 的新手,但运行此程序时出现以下错误:程序中的流浪 '\222'

unsigned long *new_intel_stack(unsigned long *sp, lwpfun func, void *arg)
{
    unsigned long *ebp;  

    push(sp,arg); /* argument */
    push(sp,lwp_exit); /* for lwp return purposes */
    push(sp,func); /* function's return address */
    push(sp,0x1abcdef1); /* bogus "saved" base pointer */
    ebp=sp;   /* remember sp from this point for later */
    push(sp,0x6c6f7453); /* push initial eax, ebx, ecx, edx, esi and edi */
    push(sp,0x66206e65); 
    push(sp,0x206d6f72); 
    push(sp,0x746e6957);
    push(sp,0x32207265);
    push(sp,0x21363030);
    push(sp,ebp);  /* push initial edp */

    return sp;
}
Run Code Online (Sandbox Code Playgroud)

c assembly

0
推荐指数
1
解决办法
1万
查看次数

麻烦与argc和argv

尝试向我的程序添加命令行参数.所以我正在进行实验,无法弄清楚这对我生命的智能警告.它继续说它期待')',但我不知道为什么.

这是它不喜欢的代码:

    // Calculate average
    average = sum / ( argc – 1 );   
Run Code Online (Sandbox Code Playgroud)

然后它强调减法运算符.以下是完整的计划.

#include <iostream>

int main( int argc, char *argv[] )
{
    float average;
    int sum = 0;

    // Valid number of arguments?
    if ( argc > 1 ) 
    {
       // Loop through arguments ignoring the first which is
       // the name and path of this program
       for ( int i = 1; i < argc; i++ ) 
       {
           // Convert cString to int 
           sum += atoi( …
Run Code Online (Sandbox Code Playgroud)

c++ argv argc

0
推荐指数
1
解决办法
906
查看次数

stray在C中查找错误

我不知道为什么这个语法错误出现在这个程序中.

#include <stdio.h>
#include <stdbool.h>

#define N 30

int main(void) {
    char sieve[N], *sp;
    int number;
    for(sp = sieve; sp < sieve + N;)
        *sp++ = true;          

    for(number = 3;; number += 2) {
        sp = sieve + (number – 3)/2;
        if(sp >= sieve + N)
            break;
        while(sp += number, sp < sieve + N)
            *sp = false;
    }

    printf("2\n");
    for(number = 3, sp = sieve; sp < sieve + N; number += 2, sp++) {
        if(*sp)
            printf("%d\n", number);
    } …
Run Code Online (Sandbox Code Playgroud)

c

0
推荐指数
1
解决办法
206
查看次数

程序中的杂散字符

所以我的教授给了我们一些代码,他说它应该能够编译,但我得到各种错误,不知道什么是错的,因为我对c没有任何经验.它是一个汇编语言类,我们应该编写汇编代码来匹配c代码正在做的事情.他告诉我们在c中运行程序以了解事物.

#include <stdio.h>
#define  SIZE  40

main()
{
int v[SIZE];
register int gap, i, j, temp;

/*  Initialize array to random positive integers mod 256  */
for (i = 0; i < SIZE; i++)
    v[i] = rand() & 0xFF;

/*  Display the unsorted array  */
for (i = 0; i < SIZE; i++)
    printf(“v[%-d] = %-d\n”, i, v[i]);

/*  Sort the array using a shell sort  */
for (gap = SIZE / 2; gap > 0; gap /= 2) { …
Run Code Online (Sandbox Code Playgroud)

c compiler-construction

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

标签 统计

c ×5

c++ ×4

gcc ×3

argc ×1

argv ×1

assembly ×1

cc ×1

compiler-construction ×1

compiler-errors ×1

linux ×1

objective-c ×1

shell ×1

text ×1

xcode ×1