Андрей Попов 1 / 1 / 0 Регистрация: 22.06.2017 Сообщений: 11 |
||||
1 |
||||
23.06.2017, 00:06. Показов 1299. Ответов 7 Метки нет (Все метки)
По совету с форума начал изучать C++ по книге «Герберт Шилдт — Самоучитель C++». Просьба не пинать за банальный вопрос, 2 недели как сел за C++
Миниатюры
__________________
0 |
Форумчанин 8193 / 5043 / 1437 Регистрация: 29.11.2010 Сообщений: 13,453 |
|
23.06.2017, 00:12 |
2 |
Студию переустановите
0 |
Байт |
23.06.2017, 00:18
|
Не по теме:
выдает 299 ошибок. Ха! Я помню на ПЛ-1 какую-то скобочку пропустил, так она мне 314 ошибок выдала (запомнил, потому что число красивое):)
0 |
TRam_ зомбяк 1564 / 1213 / 345 Регистрация: 14.05.2017 Сообщений: 3,936 |
||||
23.06.2017, 00:18 |
4 |
|||
http://www.cplusplus.com/reference/cstdio/gets/ Compatibility То есть чисто теоретически эта функция в текущей студии не заработает. Ну а так можно попробовать обрамить
вдруг поможет
0 |
hoggy 8719 / 4299 / 958 Регистрация: 15.11.2014 Сообщений: 9,744 |
||||||||
23.06.2017, 00:27 |
5 |
|||||||
выдает 299 ошибок. Код source_file.cpp:11:1: error: stray ‘343’ in program char str[80]; ^ source_file.cpp:11:1: error: stray ‘200’ in program source_file.cpp:11:1: error: stray ‘200’ in program source_file.cpp:13:1: error: stray ‘343’ in program cout << "Введите строку: "; ^ source_file.cpp:13:1: error: stray ‘200’ in program source_file.cpp:13:1: error: stray ‘200’ in program source_file.cpp:15:1: error: stray ‘343’ in program gets(str); // Считываем строку с клавиатуры. ^ source_file.cpp:15:1: error: stray ‘200’ in program source_file.cpp:15:1: error: stray ‘200’ in program source_file.cpp:17:1: error: stray ‘343’ in program cout << "Вот ваша строка: "; ^ source_file.cpp:17:1: error: stray ‘200’ in program source_file.cpp:17:1: error: stray ‘200’ in program source_file.cpp:19:1: error: stray ‘343’ in program cout << str; ^ source_file.cpp:19:1: error: stray ‘200’ in program source_file.cpp:19:1: error: stray ‘200’ in program source_file.cpp:21:1: error: stray ‘343’ in program return 0; ^ source_file.cpp:21:1: error: stray ‘200’ in program source_file.cpp:21:1: error: stray ‘200’ in program source_file.cpp: In function ‘int main()’: source_file.cpp:15:12: error: ‘gets’ was not declared in this scope gets(str); // Считываем строку с клавиатуры. ^ такое бывает, если в исходном коде вместо английских, лекарство:
но тут вас так же ждет сюрприз: Код error C3861: 'gets': identifier not found причина: The gets and _getws functions have been removed. The gets function was removed from the C Standard Library in C11 because it cannot be used securely. The _getws function was a Microsoft extension that was equivalent to gets but for wide strings. As alternatives to these functions, consider use of fgets, fgetws, gets_s, and _getws_s. лекарство:
1 |
3433 / 2812 / 1249 Регистрация: 29.01.2016 Сообщений: 9,426 |
|
23.06.2017, 00:37 |
6 |
visual studio Какая студия? Какой тип проекта? Расширение файла с кодом?
0 |
1 / 1 / 0 Регистрация: 22.06.2017 Сообщений: 11 |
|
23.06.2017, 12:15 [ТС] |
7 |
Это не лекарство. Добавлено через 50 секунд
0 |
Форумчанин 8193 / 5043 / 1437 Регистрация: 29.11.2010 Сообщений: 13,453 |
|
23.06.2017, 12:41 |
8 |
Если вы в вашей Програмер при вводе символов поставите пробел, товар что после пробела не будет зафиксировано. используйте cin.getline. А лучше std::string + std::getline
0 |
IT_Exp Эксперт 87844 / 49110 / 22898 Регистрация: 17.06.2006 Сообщений: 92,604 |
23.06.2017, 12:41 |
Помогаю со студенческими работами здесь cstdio vs fstream из cstdio в fstream Из fstream в cstdio Из fstream в cstdio Искать еще темы с ответами Или воспользуйтесь поиском по форуму: 8 |
На чтение 4 мин. Просмотров 20 Опубликовано 15.12.2019
Я видел несколько способов создания многострочного HTML, но один из них мне показался более удобным (за исключением того, что есть способ разместить HTML на отдельной странице, что было бы здорово). Тем не менее я получаю сообщение об ошибке при попытке скомпилировать его на Arduino Ide. Это ошибки, которые я получаю:
И это мой HTML-код
Я называю это так:
Содержание
- Решение
- Другие решения
- 4 Answers 4
- 3 Answers 3
Решение
Я полагаю, вы компилируете чип ESP8266 в Arduino IDE.
Обратите внимание, что в вашем коде у вас есть:
Здесь вы использовали фигурные цитаты который НЕ символ ASCII.
Другие решения
В дополнение к вышесказанному, вам также необходимо убедиться, что любые кавычки, которые появляются внутри вашей строки, например, в сбежали. В противном случае компилятор будет рассматривать их как конец строки в кавычках и попытаться проанализировать то, что следует после, как оператор.
Чтобы избежать их, добавьте обратную косую черту, например так: ,
В качестве альтернативы вы можете использовать одинарные кавычки везде внутри вашего HTML. Они не будут конфликтовать с двойными кавычками, содержащими весь HTML.
hi I’m trying to write a program for a simple game but getting errors stray ‘342’ and ‘200’ and ‘214’ using g++ and gedit in ubuntu 13.10. the code is:
and terminal out put is:
even tried to to compile this:
and terminal says again:
can anyone help me with that?
note that I was installed ubuntu last night.
4 Answers 4
You are using a Zero Width Non Joiner character after the >> in your code. This is a unicode character that is encoded in UTF-8 as three characters with values 0x2e , 0x80 , 0x8c (or in base 8, 342 , 200 , 214 ). This probably happened because you copy and pasted some code from a document (html web page?) that uses those special characters.
The C++ language require that the whole program uses mostly the ASCII encoding, except for the content of strings or character literals (that may be in a implementation-dependent encoding). So to fix your problem, make sure that you only use simple ASCII space, quotes, double quotes and not smart characters.
I’ve copy-pasted that into Python and found out that between >> and the following space there are 3 characters: xe2 x80 x8c . Decode them as UTF-8 and you get a ZERO WIDTH NON-JOINER.
How it got into your code, I don’t know. Find it out. Anything interesting about the editor you’re using? Your keyboard layout?
Apart from what was said you have also one more error related to using variable player_choice outside its scope.
It was defined in the while loop before the code snippet above and was destroyed after exiting the loop. So using it in this if statement is illegal.
I copy pasted your code snippet, completely unmodified, and found that you have a seriously funky space character after cin >> . Look below:
Get rid of the , and you should be able to compile just fine. Depending on the editor you’re using, you may or may not be able to see it printed like this.
I copied this program and am having trouble with the void downFrequency function (I think). This is for Arduino Uno. Here are the compiler errors: Compiling ‘MY_dds’ for ‘Arduino Uno’
Here is the program:
3 Answers 3
You’ve somehow ended up with «en dash» characters, rather than normal minus signs, in the downFrequency function.
Make sure you’re editing using a text editor, not a word processor; and for each of these:
delete the marked character, and retype as a normal minus sign.
(If you’re interested in the gory details, the «dash» character is Unicode 2013, encoded in UTF-8 as three bytes with octal values 324,200,223, which is why you see those numbers in the error messages.)
Явление ошибки компиляции GCC:
b.cpp:20:1: error: stray ‘343’ in program
// Найти индекс минимального значения
^
b.cpp:20:1: error: stray ‘200’ in program
b.cpp:20:1: error: stray ‘200’ in program
b.cpp:20:1: error: stray ‘343’ in program
b.cpp:20:1: error: stray ‘200’ in program
b.cpp:20:1: error: stray ‘200’ in program
b.cpp:20:1: error: stray ‘343’ in program
b.cpp:20:1: error: stray ‘200’ in program
b.cpp:20:1: error: stray ‘200’ in program
b.cpp:20:1: error: stray ‘343’ in program
b.cpp:20:1: error: stray ‘200’ in program
b.cpp:20:1: error: stray ‘200’ in program
Это обычно вызывается копированием кода с веб-страниц.
Проверьте информацию и узнайте
Эта ошибка связана с использованием кавычек в китайском стиле или других символов полной ширины. Также есть пробел в китайском формате (это нелегко наблюдать). Необходимо удалить пробел до верхней сетки, а затем использовать вкладку.
Вы можете видеть грязных персонажей через кошку -A.
Перед удалением:
for (i=0; i<n-1; i++)$
^I{$
M-cM-^@M-^@M-cM-^@M-^@M-cM-^@M-^@M-cM-^@M-^@ //M-eM-/M-;M-fM-^IM->M-fM-^M-^@M-eM-0M-^OM-eM-^@M-<M-gM-^ZM-^DM-dM-8M-^KM-fM- M-^G$
for (pos=i, j=i+1; j<n; j++)$
if (a[pos]>a[j])$
pos=j;$
if (pos != i) {$
tmp=a[i];$
a[i]=a[pos];$
a[pos]=tmp;$
}$
^I^Iprint(a, i);$
}$
После замены на TAB:
for (i=0; i<n-1; i++)$
^I{$
^I^I//M-eM-/M-;M-fM-^IM->M-fM-^M-^@M-eM-0M-^OM-eM-^@M-<M-gM-^ZM-^DM-dM-8M-^KM-fM- M-^G$
for (pos=i, j=i+1; j<n; j++)$
if (a[pos]>a[j])$
pos=j;$
if (pos != i) {$
tmp=a[i];$
a[i]=a[pos];$
a[pos]=tmp;$
}$
^I^Iprint(a, i);$
}$
После замены на английские пробелы:
for (i=0; i<n-1; i++)$
^I{$
//M-eM-/M-;M-fM-^IM->M-fM-^M-^@M-eM-0M-^OM-eM-^@M-<M-gM-^ZM-^DM-dM-8M-^KM-fM- M-^G$
for (pos=i, j=i+1; j<n; j++)$
if (a[pos]>a[j])$
pos=j;$
if (pos != i) {$
tmp=a[i];$
a[i]=a[pos];$
a[pos]=tmp;$
}$
^I^Iprint(a, i);$
}$
Решением может быть написание сценария для фильтрации символов, а когда кто-то видит, что его можно заменить на gedit, замените его стандартными пробелами. Этот метод более трудоемкий. Особенно, когда есть много кодов. Откажитесь от идеи изменения построчно.
Подобного рода проблемы с пространственным кодированием встречались и раньше.
I copied a cpp file from the web and tried to compile with g++ in Ubuntu. It gave me a number of compile errors related to hidden characters I don’t see. I now don’t have access to my Windows 7 machine otherwise I would have solved this problem in no time. I usually copy such texts into a notepad.exe application. It does not tolerate any special characters beyond a limited ASCII set. Then I copy it back. In Ubuntu there is no such simple option.
Any suggestions to resolve this problem?
Thanks, A.
I find it odd that source code would regularly have ‘hidden’ or other unusual characters in it, particularly if you just cut-n-pasted text from a web page.
In Ubuntu there is no such simple option.
No, the option is simpler.
You can filter characters using the tr filter command.
$ mv foo.cpp foo2.cpp $ tr -cd '111240-176' < foo2.cpp > foo.cpp $ rm foo2.cpp
http://linux.die.net/man/1/tr
Hope this helps.
[edit] Fixed a typo.
Last edited on
In Ubuntu there is no such simple option
Try running dos2unix on the file
Or for possible notepad replacements — gedit, kate, vi, vim, gvim,….
Any suggestions to resolve this problem?
Step 1: Copy and paste the error that you are getting from the system.
A nice little programming exercise. Write a program to do it.
Computergeek01, this is the output for you:
|
|
It is actually a well know problem on the web. You can goodgle for «stray ‘200’ in program» and see quite a few posts.
Now, I am using gedit for the most part but yesterday I also tried vim. I think vim was thoroughly confused with those hidden characters that I could not close vim but though crushing the terminal. I also tried nano. No help there either.
I will try the dos suggestion. Thanks.
P.S. I also tried to post a URL to the website I got the code from. I cannot find it, believe it or not. I keep finding posts with the same name for the cpp file but the code is different. If I find it I will post it.
Last edited on
@tipaye
GCC doesn’t choke on stray CRs.
@Computergeek01
+ 1
@Peter87
Presumes OP both knows how to and wants to spend time doing that.
Why not just use the *nix utility that does it?
GCC doesn’t choke on stray CRs.
Didn’t think it did. Just didn’t want him to fire up vi and then panic when he sees all the «^m»
@ OP: *Facepalm* The ellipses on Lines 78 and 79 are a place holder, not actual C or C++ code. You’re supposed to replace those with a function that works with your platform or hard-code it if you’re feeling lazy, that is why there are comments at those lines indicating that you should do so.
Last edited on
I just tried duoas’ suggestion. An interesting thing happened. First I created two copies of the cpp file. Then I ran the tr command:
|
|
After the first trial the number of errors declined and I got only three lines instead of many. I decided to repeat the command thinking that perhaps another run would find the remaining stray characters but I changed the command slightly:
tr -cd '200342' < glutSolidSphere_temp2.cpp > glutSolidSphere_temp.cpp
I got a warning:
tr: warning: an unescaped backslash at end of string is not portable
I removed the backlash and tried to run the command again and again to no avail. The command r stopped working although it definitely reduced the number of hidden characters and wiped out 246 completely.
Thanks, — A.
Last edited on
computergeek01, you are probably talking about these two statements:
|
|
Thank you for the suggestion. What is the «window» the code is talking about? I am not lazy, just busy but now I am up to my ears in this stuff anyway.
Thanks, — A.
There’s nothing wrong with being lazy, my being lazy is what gives me the motivation to automate and script everything. Otherwise I’d be doing a thousand mundane and brain dead tasks a day by hand like my idiot predecessor.
But you are correct, those are the lines that I mean. The «Window» is the drawing context assigned to the process, these variables are associated with the actual visual element of the process. I’m sorry but I’m a Windows guy and I have no idea how to grab this on *nix.
Computgergeek01, thank you for suggestion again. I think you hit the right point. I replaced the ellipses with arbitrary numbers 120 for the width and 50 for the height. All those crazy errors disappeared immediately, so that was the problem. Now I got only one compile error:
|
|
I will try to figure out how I can define it but if you have a thought to share, that will be appreciated also. I have to find this function on the web somewhere.
Thanks, — A.
Last edited on
Yeah, that one is weird because «SwapBuffers()», with a capitol ‘S’, is a WinAPI function. This is going to be another platform specific one. SFML would be easy enough to integrate into this project, you should consider using that to provide your rendering context.
Thank you again, computergeek01. It bothers me that so much code posted on the web is in fact unusable because a header file is missing or some obscure function is not there, etc. Why do they post the code then?
Let me describe what my ultimate goal is. I know it is doable. I may end up writing this all code myself in Gfortran using formulas that are available in Wikipedia. It is all about projections of the 2-sphere and some functions and figures defined on it. I do a lot of special functions like Spherical Harmonics in relation to figures defined on 2-sphere. The mathematics itself is not hard but I found it difficult to visualize various images I define mathematically placed on the sphere. So, I decided to find a code that will possibly do it for me.
I checked already on SwapBuffers and found out that it is a Windows API, yes. There are also some other sites that delve into it but I could not find anywhere the actual file posted, for the most part it is all some philosophy about it. Also I think it is considered outdated and not supported although I don’t know what support the file needs.
If you have any good thoughts, please post them. That idea of yours to remove the ellipses was a winner.
I will try the SFML although I am wary of gamers and such. If this software is favourite of gamers it may be difficult for me to use.
Thanks.
— A.
Last edited on
Topic archived. No new replies allowed.