Windows 10: "The ampersand () character is not allowed" [closed] - c

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I am learning C language. I installed and configurated everything to start coding
But when I try to use ampersand (&) in scanf my program doesn't compile:
scanf("%f", &x);
I am getting this error:
The ampersand () character is not allowed. The & operator is reserved
for future use; wrap an ampersand in double quotation marks ("&") to
pass it as part of a string.

I don't think you have everything installed and configured correctly.
The error looks like a PowerShell error, not a C compilation error.
Get a C compiler like MinGW-w64 GCC from http://winlibs.com/ and make sure to compile your C code (there is an example on that website showing you how to compile from the Command Prompt).

Sorry my bad, I had to change my file extension from .cpp to .c to make it work correctly.

Related

What does a C #include statement do in a Fortran code? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
In the middle of a code there is a C language statement. I don't know why it is there and how the compiler does not give back an error. Is it for C binding? Does it mean that this module can be used by C program or vice versa?
USE LISTS
USE LINKEDLIST_ROUTINES
#include "macros.h"
IMPLICIT NONE
PRIVATE
It is not a C language statement, but a C preprocessor (cpp) statement.
Any text file can use the preprocessor, even Fortran source codes, but you must call the preprocessor before compiling.
Many Fortran compilers will call the preprocessor for you with flags -cpp or -fpp or similar. They might also call it for you if the file suffix starts with capital F.
What the #include "file" does is the same as what it does in C source files, it inserts the text from the file in that location.
There is also a standard Fortran (90+) statement include. It is similar, but happens after any eventual pre-processing has been done, see Includes revealing with Fortran preprocessor for more.

Trouble building regex to compile with regcomp [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am trying to build a regular expression to satisfy strings like the following: ${AnyTextHere}. This is what I have right now: \\${[a-zA-Z0-9]+} It works in some online regular expression checkers, but not with regcomp.
You may also have to escape curly braces {, as they are considered regex special characters.
\\$\\{[a-zA-Z0-9]+\\}
^ ^
see regex demo

No sound with \a in cygwin [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I'm doing some coding using cygwin with c programming. There is no sound with \a. Do I have to install some packages? There is no problem with cl compiler.
#include <stdio.h>
int main()
{
printf("\a");
return 0;
}
with the following setting
gcc test.c -o fun.exe
I am going to guess that it has something to do with the terminal emulator you are using. I am using mintty. When I edit the options, I am able to specify the behavior of "Bell".
When uncheck "Sound" I don't hear anything. When I check "Sound", I hear a beep.

Linking files with LD [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I read this tutorial: http://www.osdever.net/tutorials/view/writing-a-simple-c-kernel
I tried linking the files using the likerscript that the tutorial provides. But LD gives me an error saying that it cannot read the file put out by nasm. Does anyone know what I am doing wrong?
If you executed the tutorial precisely as shown, then the problem is most likely here:
nasm -f aout kernel_start.asm -o ks.o
This produces an object file in the thoroughly obsolete a.out format. You're probably working through the tutorial on either a Windows or a Linux host system; the linkers that come with these systems expect object files in PECOFF and ELF format, respectively. There is probably another thing you can put after the -f in the above command that will make nasm produce the correct format.
Alternatively, learn to write AT&T assembly language instead. Then you can make an object file out of your .asm file with gcc -c just like the C source code, and you will automatically get the right format. The AT&T equivalent of the trivial startup file you have in that tutorial would be
.text
.globl start
start:
call k_main
cli
hlt
Take note also that I removed the leading underscore from the call instruction's argument. That underscore is only appropriate if the C code is compiled to an a.out-format object file, which (we suspect) it isn't.

How to call a flex parser in c [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How to call a flex parser in c ?
By calling yylex().
By default lex reads from stdin, if you want it to read from other stream, assign yyin, like
yyin = fopen("myfile", "r");
It's worth noting that yylex is not declared anywhere so you need to declare it:
int yylex ();
Traditionally it seems that the entire output of lex or flex would be incorporated in the C program via #include.
Recent versions of Flex include an option to create a header file, either on the command line via the
--header-file
option, or in the script
%option header-file
The header file contains stuff which can be used, for example, to ask Flex to read from memory rather than a file.

Resources