Stack Overflow » C#
255 FOLLOWERS
Stack Overflow empowers the world to develop technology through collective knowledge. This section is a place to discuss about general questions concerning the C# language, as defined in the ISO 9899 standard. Learn how to get http call times in C# task.whenall method, how to make an API support DICOMweb Standard, and more.
Stack Overflow » C#
11h ago
In my C program, I am trying to convert .asm code to pseudo-machine code.
Assembly file used:
ORG 0x10
start WB 0x05 ; write 0x05 to MBR
WM 0x400 ; write data on MBR to memory at address 0x400
WB 0x03 ; write 0x03 to MBR
WM 0x401 ; write data on MBR to memory at address 0x401
RM 0x400 ; read address 0x400, store data to MBR
WACC ; write MBR to ACC (via BUS)
RM 0x401 ; read data at memory address 0x401, store to MBR
ADD ; add ACC to MBR (through BUS)
RACC ; read ACC, store to MBR
WM 0x402 ; write data on MBR to memory ad ..read more
Stack Overflow » C#
11h ago
#include <stdio.h>
#include <stdlib.h>
#include <systemd/sd-device.h>
int main() {
sd_device *device;
sd_device_enumerator *enumerator =NULL;
const char **subsystem =NULL;
// *subsystem = malloc(sizeof(char *));
*subsystem = malloc(500);
if (subsystem == NULL)
printf("ohh");
// Create a device enumerator
int r = sd_device_enumerator_new(&enumerator);
if (r< 0)
printf("unable to create instance");
printf("%d\n",r);
//sd_device_enumerator_scan(enumerator);
for (device = sd_device_enumerator_get_device_f ..read more
Stack Overflow » C#
11h ago
I am trying to implement an n bit adder in Systemc. However, I am quite new to the language and I think I need a generic parameter to instantiate n-1 full and one half adder. I do not find anything regarding this online. Can someone help me ..read more
Stack Overflow » C#
11h ago
explain the question and input format
please explain the question briefly.MIN To MAX You are given an array ? A of size ? N.
Let ? M be the minimum value present in the array initially. In one operation, you can choose an element ? ? A i
( 1 ≤ ? ≤ ? ) (1≤i≤N) and an integer ? X ( 1 ≤ ? ≤ 100 ) (1≤X≤100), and set ? ?
? A i =X.
Determine the minimum number of operations required to make ? M the maximum value in the array ? A.
Input Format The first line of input will contain a single integer ? T, denoting the number of test cases. Each test case consists of multiple lines of input. The first ..read more
Stack Overflow » C#
11h ago
I am attempting to find the median from an array of data in c, every time I attempt to though, I get zero even though there is only one zero in the array, the array is sorted before being imputed to the function. the array data is valid as I can calculate the average and the sum correctly.
Here is my function:
//The array is sorted prior to this
//count is the amount of values in the array
double median(int64_t *array)
{
double q2;
int64_t pos, pos1;
if (count % 2 == 0)
{
//even
pos = count / 2;
pos1 = (count ..read more
Stack Overflow » C#
11h ago
I asked AI (Claude), and it told me it is UB. Is that real?
#include <stdio.h>
struct BitFieldStruct {
unsigned int a : 5;
unsigned int : 3; // 3位填充位
unsigned int b : 6;
unsigned int c : 10;
};
int main() {
struct BitFieldStruct s1 = {10, 20, 300};
struct BitFieldStruct s2;
printf("s1.a = %d, s1.b = %d, s1.c = %d\n", s1.a, s1.b, s1.c);
s2 = s1; // UB
printf("s2.a = %d, s2.b = %d, s2.c = %d\n", s2.a, s2.b, s2.c);
// may not same as s1
return 0;
}
I searched the internet and was still confused.
Claude told me that it is according C99(6.7 ..read more
Stack Overflow » C#
11h ago
The chip I use is STM32G473VC, which is configured with 7 channel ADC and SPI slave station
When the SPI DMA transmission is not started, the ADC works fine.
However, when the SPI DMA transfer is started, the ADC occasionally reads a value of 0.
The transmission cycle of the SPI master station is 8ms. SPI needs to transmit important data, so SPI has a higher priority than ADC.
Whether I use the ADC DMA, interrupt, or direct poll conversion to read the register, it is possible for this 0 value to occur.
What might be the cause of this ..read more
Stack Overflow » C#
11h ago
I am trying to use the Cell Updates Per Second (CUPS) metric to measure the performance of the sequence alignment algorithm. I saw the metric being used in several papers but none of them have explained how it is really being computed.
It is essentially processing the cells in a 2D matrix.
What I tried is as follows:
gettimeofday(&tv1, NULL);
alignment_score = alignment(seq1, seq2, seq1_len, seq2_len);
gettimeofday(&tv2, NULL);
double elapsed_time = (double) (tv2.tv_usec - tv1.tv_usec) / 1000000 +(double) (tv2.tv_sec - tv1.tv_sec);
printf ("elapsed time = %f seconds\n",elapsed_time ..read more
Stack Overflow » C#
11h ago
When compiling with clang, I noticed that the order of the warning output was different for each compilation.
For example, The output was as follows
foo.c:473:20: warning: implicit conversion loses integer precision: 'long' to 'short' [-Wimplicit-int-conversion]
b2 = s2 ;
~ ^~~~~~~~~
foo.c:360:14: warning: variable 's1' set but not used [-Wunused-but-set-variable]
long s1 = 0 ;
^
foo.:353:21: warning: variable 'l2' set but not used [-Wunused-but-set-variable]
long l2 = 0 ;
^
foo.c:352:21: warning: varia ..read more
Stack Overflow » C#
11h ago
I'm a new bike in C language, after some simple examples and best practices of how to use regular expressions in ANSI C. I have simple test, want to get date in an description string bellow "{d(02/01/2019)}-call Ms.ha check this case". I mean want to get "02/01/2019" this is my code
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <regex.h>
#define ARRAY_SIZE(arr) (sizeof((arr)) / sizeof((arr)[0]))
// initialize target string and regular expression string
int main(int argc, char **argv)
{
regex_t preg;
char *string = "{d(02/01/2019 ..read more