Skip to main content

All Questions

Tagged with
0 votes
1 answer
62 views

Assigning values in loop body?

I am trying to build an array for which each element is 2 times the previous element. I tried using below loop but am getting error variables 'x' and 'length' used in loop condition not modified in ...
lm.bertrand's user avatar
0 votes
1 answer
114 views

Why does this C word histogram program print an overflow of 0?

I am studying from the K&R C Programming Edition and one of the exercises (1-13) is to print a word length histogram which I mostly succeeded in doing. However, there is one issue. if (nc < ...
Sean's user avatar
  • 27
0 votes
0 answers
56 views

Initializing an array of pointers to structs using double pointer

Hello i am currently writing a program to emulate bouldering in real life, where there is a Wall ADT where you can store certain rocks on the wall which is represented basically as a 2d matrix. ...
Alex's user avatar
  • 23
0 votes
2 answers
73 views

Beginner in C: Can't properly printf first and last element in double array?

I'm trying to display a Wish List on the command line. The user enters the cost of the item, the level of priority (1-3), and whether or not it has financing options (y/n). The inputted values are put ...
chickpea's user avatar
0 votes
1 answer
39 views

Why is my histogram implementation segfaulting even though it shouldn't because I'm looking for values inside bound?

So, the histogram I implemented, basically takes a string as input, and divides it into words, and then the length of that word is used as the index, the output is an integer array. a[p]++, if strlen(...
FariyaAchhab's user avatar
0 votes
1 answer
86 views

How can I read a large set of data from a file into either a pointer to a structure or array of a structure in C

I have a data file with a known key, that is, it has many entries (devices) with the same properties and I have this structure in code to capture it. struct deviceData{ int id; char serial[10]; ...
PandaBanda's user avatar
0 votes
1 answer
43 views

C - Linked list printing extra link

My program is printing one more link, at the beginning, than what I'm supposed to have. I can't find the problem in my debugging. Also, I'm unsure if my sorting is optimal. I've added the text I'm ...
LIsa's user avatar
  • 173
1 vote
1 answer
68 views

C Losing pointer to pointer reference

Im able to find the most frequent letter, but when trying to print the elements in **words again, Im given \000 values. I tried to store head into another variable but seems like I still lose all ...
Olivia22's user avatar
  • 151
0 votes
2 answers
175 views

C fscanf to read each word from a file not working

I already know how read word by word from a file (using fgets then strok each other), however itd like to find the simplest way and from what Ive seen fscanf, should work. If fscanf will allocate the ...
LIsa's user avatar
  • 173
0 votes
2 answers
48 views

C, values in array of pointers dissapear (pointers)

I seem to be losing the reference to my pointers here. I dont know why but I suspect its the pointer returned by fgets that messes this up. I was told a good way to read words from a file was to get ...
LIsa's user avatar
  • 173
0 votes
0 answers
432 views

BYTE data type variable value in debugger

This is in relation to my last post about finding the start of JPEGs and creating new jpg files with each new found JPEG. I am only getting part of one JPEG after running the below code (instead of ...
Duke3e33's user avatar
  • 321
1 vote
4 answers
153 views

Why am I geting floating point exception?

This program worked fine when i manually iterated over 5 individual variables but when I substituted them for those arrays and for loop, I started getting floating point exceptions. I have tried ...
xImperiak's user avatar
  • 384
0 votes
0 answers
46 views

Countof macro erroneously returning 1 [duplicate]

I'm trying to print an array, however it is only printing one element of the array. void printArr(int arr[]) { int a; for (a = 0; a < _countof(arr); a++) { printf("%i, &...
CProgrammer15's user avatar
3 votes
2 answers
160 views

Problem entering values to typedef char array in C

in my code I have this typedef char: typedef char chessPos[2]; and when I try to debug and see the the values I try to enter chessPos* pos; *pos[0] = 'C'; *pos[1] = '3’; after debugging I get that ...
Avi_M's user avatar
  • 33
0 votes
1 answer
478 views

Can't assign variable length array size by scanf()

I am trying to get user input using scanf() to get the array size. There are 2 arrays, the scanf() asks for 2 numbers separated by a space. The first array's size can never be assigned but the second ...
ENG_MOH's user avatar

15 30 50 per page
1
2 3 4 5