C is a general-purpose computer programming language used for operating systems, games and other high performance work and is clearly distinct from C++. It was developed in 1972 by Dennis Ritchie for use with the Unix operating system.
0
votes
0answers
4 views
How to compile a program in C with IAR for msp430x5438A when i get the following error?
i am using IAR for msp430xf5438A and when i am trying to compile my program i get an the following error: Internal Error: [TaInstr::Validate]: Instruction does not match requirement. what can i do to ...
-1
votes
0answers
19 views
device notification in c when a flash insert
some one in this page give me this code for detecting the flash in C but when i run it gave me
an empty window that its title in chines and when i debug it,it doesn't shows that when exactly it run ...
-1
votes
0answers
31 views
Is this not tail recursive? (stack overflow error)
This is a small function I have written to check whether an integer is a prime or not:
int prime(int x, int y = 2)
{
if(y <= x/2)
{
if((x % y) == 0)
return 0;
}
...
0
votes
3answers
45 views
Are constant expressions calculated at compile time if they also need type conversion?
Say I have an assignment like this:
int i = 3.6 * 3 * 3600;
Will the compiler evaluate this at compile time using floating point maths and convert the result to an integer? Will it get the right ...
0
votes
3answers
37 views
C- Fix Stack overflow in Recursion
A code in C to find maximum of an array using divide and conquer but it keeps throwing
"stack overflow exception" . Help would be appreciated!
int a[10];
int find(int l,int h)
{
int x;
...
0
votes
3answers
40 views
C++, cooperating FILE* and std streams
I need to use an existing C library in a C++ project.
My problem is the C existing library uses FILE* as streams, is there a standard compliant way to use FILE* streams to put or to get from C++ ...
0
votes
2answers
55 views
C failed while allocating memory
I am creating an arraylist in C, each time I try to reallocate the array (for expanding it) the third time, I get this error message:
malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) ...
1
vote
3answers
40 views
Setting CPU affinity to a process - C - Linux
Not the best in C programming, here is my first trial to port a program from python to C.
Credits to Alnitak for the program below
#include<sched.h>
void task_set(int pid) {
int ...
0
votes
2answers
23 views
Creating multiple arrays dynamically in C/Fortran based on loop iterator
I want to create multiple arrays based on the iterations of a loop in C.
For example:
int i, size;
for ( i =0; i< 10; i++)
{
size = i * 100
create_array(i,size); // This loop iterates 9 ...
0
votes
3answers
37 views
possible way to implement array of pointers to string
I had a code which works fine with the integers
#include<stdio.h>
int main()
{
int i;
int* p[5];
printf("Enter the elements to be shorted");
for(i=0;i<=4;i++)
{
scanf("%d\n",&p[i]);
...
0
votes
1answer
16 views
Trying to read a file of tab-delimited strings and put them into an array and output, but I am only getting one character?
I generated a simple tab-delimited file that is of the following format:
a aa aaa
b bb bbb
...
...
y yy yyy
z zz zzz
I am trying to read the file line-by-line, and put the ...
0
votes
0answers
15 views
FreeBSD headers
Help me out with headers #include "sys/prctl" and "sys/resources" equivalent in freeBSD OS.
In linux is for operations on a process like dump memory etc. Can anyone help me out with equivalent of ...
1
vote
1answer
19 views
Multi-threaded speed-up only after making array private
I am trying to learn multi-threaded programming using openmp. To begin with, I was testing out a nested loop with a large number of array access operations, and then parallelizing it. I am attaching ...
0
votes
3answers
31 views
Find permutations of a list of numbers with increasing length in C
Consider the following list of numbers: 0, 1, 2, 3
I am trying to find all permutations of the list of length 2, 3 and 4.
i.e.
(0, 1)
(0, 2)
(0, 3)
(1, 0)
(1, 2)
(1, 3)
(2, 0)
(2, 1)
(2, 3)
(3, 0)
...
0
votes
3answers
37 views
Convert any variable to string in C
Is is possible to convert any variable of any type to string?
I wrote the following
#define TO_STRING(val) #val
Is this a valid way of converting a variable into a string?