Skip to main content

All Questions

Tagged with
1 vote
1 answer
136 views

Can't understand this C syntax. Designated initialization of an array of structs?

Trying to learn the nuances of C, though I was doing well until I found this: #define SOKOL_IMPL #define SOKOL_GLES3 #include "sokol_gfx.h" #include "sokol_log.h" #include "...
Matheus de Moraes Peixoto's user avatar
2 votes
3 answers
113 views

Converting to char*** from char* [2][2]

I have the following variable char* a[2][2] = {{"123", "456"}, {"234", "567"}}; I wanted to refer it using another variable. While the cast works, accessing ...
Sreepathy's user avatar
1 vote
3 answers
75 views

In C, why can a variable holding a char array be assigned to a pointer, but the address of the same pointer cannot?

Consider the following code: char stringy[] = "There's too much confusion, I can't get no relief!"; char *pStringy; pStringy = stringy; This compiles - stringy is an array of characters, ...
Bennypr0fane's user avatar
-1 votes
0 answers
43 views

I need help reversing an array in C [duplicate]

Hey I'm a beginner to C so please excuse any beginner mistakes I make on this platform. I am trying to write a program that reverses the order of the elements elements of an array and prints it. I ...
Draj136's user avatar
0 votes
2 answers
61 views

Is the & operator is essential to use as address operator [duplicate]

#include<stdio.h> int main() { int a[5]={5,10,15,20,25}; int *p; int i; p=a; for (i=0;i<=5;i++) { printf("the address of the %d is = %d\n",*p,p); ...
khushal dak's user avatar
-1 votes
1 answer
88 views

write a programme in c to skip 2 elements after occurence of a non prime

I write the code as my knowledge but i didnt get the correct ouput.i provide my code below #include <stdio.h> int main() { int i, j, isPrime, n, a[1000], k; // Input array limit ...
Misthah Kp's user avatar
-3 votes
1 answer
83 views

Why does incrementing a pointer to an array give this result?

If I define a new (int) array, and increment the dereferenced pointer to this array by 1, why do I get the following result? int main() { int myArray[1024]; myArray[0] = 123; myArray[...
evstack's user avatar
0 votes
1 answer
62 views

Why does my C program with any input results in segmentation fault?

I've spent hours of racking my brain on why doesn't this work #include <stdio.h> #define MAXLINE 1000 #define TRUE 1 #define FALSE 0 int getLine(char s[], int lim); void copy(char to[], char ...
JERVIS JAMES PEDOTIM's user avatar
0 votes
0 answers
29 views

unable to take input of strings from user [duplicate]

I have to make an array of structure for cricketers presenting their name, age etc. and take input of each value from user . I am trying to get value of name from the user but my code editor keeps on ...
Harshit Gupta 's user avatar
2 votes
3 answers
103 views

Do brackets have effect during array of pointers declaration?

Recently I was reading "The C programming language" text book by Brain and Dennis and encountered that there is a difference between the pointer array definitions shown below: int (*a)[10]; ...
Abenaki's user avatar
  • 25
0 votes
0 answers
38 views

How do I dynamically allocate memory for a multidimentional array in C? [duplicate]

Dynamically allocate memory for a multidimensional array (matrix) with a specified number of rows and columns. How to allocate memory? How to allocate memory for 2D array? How to dynamically allocate ...
Samhitha Harini's user avatar
0 votes
1 answer
50 views

How to use `static` with an array of array in C

Given, int last(int arr[3][6]) { return arr[2][5]; } I want to make it clear that arr can't be null with the static keyword. The problem is that the following code won't work. int last(int arr[...
gberth's user avatar
  • 670
1 vote
1 answer
62 views

cppcheck out of bound error with dynamic array size

I have the gpio initialization code (sample below). It is compiled without any issues and is executing properly. typedef enum { USER_LED = 0, DEBUG_UART_TX, DEBUG_UART_RX, ...
hariudkmr's user avatar
  • 327
1 vote
0 answers
46 views

I can't understand why the first value that I add to the last is not the true value [closed]

void process_data_directive(struct as_tree *node, char *line) { struct string_sep_result ssr = {0}; // Initialize ssr to avoid any uninitialized memory issues int count = get_dir_data_val(line,...
lol's user avatar
  • 11
1 vote
3 answers
117 views

C can't access array

I am writing a C program that lists students and adds students, but when I add a new student, although I can read the value successfully, the function can only print the first 2 elements to the screen ...
Emmet's user avatar
  • 35

15 30 50 per page
1
2 3 4 5
2025