How to read mex.c file in Matlab code [closed] - c

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
I have a Matlab code for measurement and when I try to run it this error pops up:
Undefined function `mexLoadMeasurements` for input arguments of type `char`.
Error in LoadMeasurements (line 56)
measurements = mexLoadMeasurements(attr.Name);
I also have the file measurements_io.mex.c in my directory, but I don't know how to make it readable for Matlab to run my code.
Thanks

You need to compile the c file into a mex library (in matlab).
Setup your Matlab's mex compiler:
>> mex -setup
Compile the c source code
>> mex -largeArrayDims -O measurements_io.mex.c -output mexLoadMeasurements
Read more about mex files here.

Related

Windows 10: "The ampersand () character is not allowed" [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 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.

how do I solve build and run error in this code of C using CodeBlocks? [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 am new to programming world and started with C and i want to build and run this code but it says error or multiple main function, the code is:
#include <stdio.h>
int main()
{
int age;
printf("I got %d%% on my C exam\n",98);
return 0;
}
You probably created a default project with an existing C source file containing a main, then you probably added a new file to type your code that contains a main, and then the IDE complains when compiling because you have two mains. Remove the default file from the project.

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