Skip to main content

Questions tagged [array]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
26 views

CS50 Pset 2 Substitution - Array size errors

I'm using a for loop to assign chars to each element of an array one at a time. The array has been assigned a size and the for loop runs the same number of iterations as the array size, but I find ...
DavidM's user avatar
  • 3
3 votes
2 answers
58 views

Why can you say the name of an array is a pointer to the first element of the array in C?

I have tried to understand why you can say the name of an array is a pointer to its first element in C. Could you please tell me if my understanding below is correct? Both the name of an array and the ...
Yuya Ito's user avatar
-1 votes
1 answer
47 views

Pset 4 Filter (More) -- PLZ HELP

When I declare the array earlier, I end up with the wrong output. But when I declare it inside the loop, the final output is correct. Plz tell me how to explain this. The wrong one: void edges(int ...
xyj's user avatar
  • 1
0 votes
1 answer
41 views

pset1 credit 2023 , do while loop with arrays/intervals

#include <cs50.h> #include <stdio.h> int main(void) { long n; do { n = get_long("13 digits or at max 15, 16 card number: "); } while(n < ...
REJEN RJ's user avatar
0 votes
1 answer
21 views

Argument list in c

what is an argument list in c? Please I need a very simple explanation that if possible I'll remember for life! also... show me one containing an array
Gold Isaac's user avatar
0 votes
1 answer
4k views

How to find if element is not in an array

Does anyone know of an easy way in C to check if a an element is NOT in a given array? I think it would be fairly easy to determine if an element IS in an array by looping through it and seeing if an ...
Joseph J Filoramo's user avatar
1 vote
0 answers
1k views

pset2 - Bulbs - reversing array turns out wrong

I managed to make the right sequence of binary code (in reverse). Next, I do a for loop for reversing it, but it prints out wrong. I have no idea what happens, as the original array is correct, ...
yogmel's user avatar
  • 11
0 votes
2 answers
270 views

pset2 bulbs - getting array out of while loop

I'm working on the pset2 Bulbs problem and I've come to a place where I don't know what to do next. This code takes user text input and converts it to ascii; I can see that the array is being filled ...
mdc690's user avatar
  • 1
0 votes
1 answer
106 views

Converting an array to lowercase

I am trying to convert an array to lowercase, and store the values as a new array. #include <cs50.h> #include <stdio.h> #include <ctype.h> int main(int argc, string argv[]) { ...
lxs602's user avatar
  • 1
0 votes
1 answer
829 views

comparison between pointer and integer ('const char' and 'char')

I'm not familiar with C, not sure what this error means.. could anyone help? #include <ctype.h> #include <cs50.h> #include <stdio.h> #include <string.h> // Points assigned to ...
matt.mcg's user avatar
  • 101
0 votes
1 answer
203 views

Undeclared Identifier error in array

In the code below (photo), I am trying to index into the two different arrays, one with capital letters and one with lowercase letters. When I make this program, I keep getting the following error ...
Joseph J Filoramo's user avatar
0 votes
1 answer
69 views

How to get accurate float average of numbers

I'm in Lecture 2 on Arrays, and I am playing with the example Professor Malan gave about taking a user's input for the number of test scores, as well as for the scores themselves, and outputting the ...
Joseph J Filoramo's user avatar
0 votes
1 answer
24 views

substitution question segmentation fault issue

I am doing the substitution question and I keep running into this segmentation fault issue but i do not understand what exactly is causing the memory access issue. once j=4, the memory fails to be ...
Damien Lim's user avatar
0 votes
1 answer
478 views

Use of undeclared identifier 'num'

I dont really know where im wrong. it gives me "use of undeclared identifier 'num'" i allready tried to solve it but i have no clue of what is going on #include <stdio.h> int maxc = 0,...
Ricardo Martínez Focas's user avatar
0 votes
1 answer
28 views

Why is an Array longer then the input?

why we can access more information than the lenght of the array? I thought that after the Null (0) the array ends. Why we can access position 40?
PeterWolfe's user avatar
0 votes
3 answers
34 views

Error retrieving return values ​from a function

I am currently studying coding in C language and I have doubts about the return of functions, what I am trying to do is the following: Call the number () function and pass 3 values ​​of the integer ...
Code Maker's user avatar
0 votes
1 answer
66 views

Help with Either Command Line Argument or Arrays for Problem set 2 Caesar

I am on Problem Set 2: Caesar. Right now I'm trying to write code that first checks if the second command line argument is a int and if it does prints the integer. I got my program to compile after ...
Dre Johnson's user avatar
0 votes
1 answer
40 views

When I'm creating array

This has me confused. In the following code, I create an array of characters initialized at size 7. The array needs to store at least 6 characters, so I've made it large enough to do that (I think?). ...
WhatEvenIsCoding's user avatar
0 votes
2 answers
1k views

Caesar : Extra random characters at the end of a char ciphertext array

I'm having a problem with an output. Sometimes output adds an extra characters, different each time the code runs. For example, when I use key "1" and write "a", it displays "...
D3sl0nG3r's user avatar
0 votes
1 answer
90 views

Having Trouble using StrCpy with Command Line argument for Problem Set 2 Caesar. Trouble with Array

Hello I'm still fairly raw at this coding thing so i'm sure im making rookie mistakes. I'm doing Problem Set 2 caesar and I've hit a wall and haven't been able to move forward. What I have been trying ...
Dre Johnson's user avatar
0 votes
1 answer
17 views

How can i arrange the output in decending order In this program? [closed]

#include <stdio.h> int main() { int n,i; printf("Enter a number: "); scanf("%d",&n); for (i=0; i<=n; ++i) { if (i%(7*13*19)==0) { ...
Khulit's user avatar
  • 3
0 votes
1 answer
26 views

PSet 5 Speller - Expected Identifier

Been stuck on Speller for 2 days and could really please use some help. My initial idea is just to create an array of linked lists with 26 buckets (N = 26) and very simply hash the words by only the ...
Andrew's user avatar
  • 3
0 votes
1 answer
75 views

Getting different outputs when I use debug50 and when I run the program

When I use debug50 on this program I get 26 as the value of 'a' but when I run it I get random large values of 'a'. #include <cs50.h> #include <stdio.h> #include <string.h> #include &...
Aakash Malviya's user avatar
0 votes
1 answer
1k views

cs50 array initializer must be an initializer list

i have started coding in c but i keep getting errors i don,t know how to solve maybe it is because i am used to coding in php language but i hope anybody can help me #include <stdio.h> #include &...
mich's user avatar
  • 1
0 votes
1 answer
40 views

Having trouble identifying non-decimal digit in Caesar PSET 2

I'm working on Caesar from Problem Set 2. I have done the first step to check for a single command line argument, but I'm stuck on how to check the argument to see if any characters are non - decimal ...
Liz-Sod497's user avatar
1 vote
1 answer
294 views

Week 2 passing array example problem?

Hi, I have problem understanding the concept of 'passing an array by reference instead of value' and I cant understand this example. Can anyone explain to me why does it take 10, 22 as final answer?
xxtan1's user avatar
  • 13
0 votes
1 answer
30 views

When I multiply my array by 2 it doesn't give expected value

Also, please when I try to add "firstnumsum", it doesn't give expected value and I don't know what to do. #include <cs50.h> #include <stdio.h> #include <string.h> #include &...
Gloria Isedu's user avatar
0 votes
1 answer
103 views

Readability compiling issue

Readability (Problem Set 2) #include <stdio.h> #include <cs50.h> #include <string.h> #include <ctype.h> #include <math.h> // Letters detects letters // Words detects ...
starbvuks's user avatar
0 votes
1 answer
59 views

My code for Caesar gets segmentation error when executed, but in debugger it works fine

I'm getting a segmentation error as soon as I execute this program. I've run it through the debugger and it works fine and outputs the correct ciphertext. There's gotta be something going on in the ...
Brandon Zemel's user avatar
0 votes
1 answer
307 views

check50 claiming pairs are sorted incorrectly

On Problem Set 3, check50 has flagged my program as not having sorted the pairs correctly. However, the pairs array appears to be sorted in every case I've tried. I used insertion sort and had ...
Gabriel Saul's user avatar
0 votes
1 answer
56 views

Why is this generating wrong output and Runtime - out of bound error?

I have a program below, which gets some random numbers from users and then multiply every second to the last digit by 2, stores it into an array and print out the value of each array index. It seems ...
KeleosWilliam's user avatar
0 votes
1 answer
43 views

In pset2, Vigenere, I made and used an array that I would like for it to be explained

I’ve successfully solved Caesar and Vigenere pset but made and used an array that I stumbled upon through trial and error but don’t exactly know why and how it worked. I’m hoping someone could clarify ...
Jovanovic's user avatar
0 votes
1 answer
32 views

PSet2 why isn't this providing output

This segment of code only prints out blank lines. Key is the correct integer, but I must be handling the array of characters incorrectly. Thoughts? int key = atoi(argv[1]); for (int i = 0, c = ...
KayO133's user avatar
  • 33
0 votes
2 answers
141 views

Pset3 Resize Array not storing data properly

I'm not sure where the issue is here, but from the looks of debug I only store anything in my horizontal array (line) once despite seeing the debugger hitting that section of code properly. I assume I ...
De1337ny's user avatar
0 votes
1 answer
62 views

Pset2 Vigenere, array with garbage

I am getting some garbage values when declaring my array. I kinda understand that when declaring without initializing it provides garbage values, but I don't understand why the array is larger than ...
nBock's user avatar
  • 13
0 votes
1 answer
79 views

Caesar not getting output

I'm stuck troubleshooting what is wrong with my code. It prompts for plaintext correctly, but when entered returns a blank "ciphertext: ". # include <stdio.h> # include <cs50.h> # include ...
Beyn18's user avatar
  • 21
0 votes
1 answer
135 views

Why string variable has no square bracket?

Though it's said that string is an array of characters why string variable does not have square brackets on the immediate right? In CS50 we call string as string s why not as string[]? then how can ...
Indhlal Amrith's user avatar
1 vote
1 answer
698 views

array size in C

I have question regarding array size declaration in C. I see that if I declare an array in the main function without specifying its size like int arr[]; arr[0] = 7; arr[1]= 8; it shows an error ...
sk.76's user avatar
  • 312
0 votes
1 answer
147 views

How to get maximum element of array from index a to index b?

I keep getting the error format specifies type 'int' but the argument has type 'int ()(int , int, int)'. printf("%d", get_max); I'm new to pointers and coding C in general and still haven't ...
Bel's user avatar
  • 1
0 votes
1 answer
27 views

Why am I able to insert an element into a hash tree via Main() but not via a function call?

I'm fairly certain this has something to do with pointers and the function using copies instead, but I'm not sure how...because I've inserted the pointer as a parameter for create(); #include <...
Krishaan Khubchand's user avatar
1 vote
1 answer
132 views

Pset2: Copying string contents

I just can't seem to get this right. The example in the week 2 short Arrays is as follows: int foo[5]{1,2,3,4,5}; int bar[5] for(j=0;j<5;j++) { bar[j]=foo[j]; } This does not seem to work with ...
contranull's user avatar
0 votes
1 answer
421 views

CS50 PSET2 code will not compile

I would appreciate any help that could be given with my code below (+ error codes below that): My code will not compile and the primary error apparently is an "undeclared identifier" refering to ...
Pot Noodle's user avatar
0 votes
1 answer
768 views

Problem accessing the last element of the array

I've decided to implement the load function using trie, which I've defined as typdef struct trie { struct trie letters[27]; bool isWord; }trie; then later, when I try to ...
Mohit Jha's user avatar
0 votes
1 answer
37 views

Pset4 - Array declaration- Heap

In shorts of Pset4 it was mentioned, that pointers are created in heap. Does it mean, that all arrays are stored in heap?
LCK's user avatar
  • 15
0 votes
1 answer
91 views

Pset5 Dictionary C Struct Array Call In Load Function Issue

I've defined the struct as following: // Node struct typedef struct node { // Node value char word[LENGTH + 1]; // Node Pointer to next value/node struct node* ...
dankthreads's user avatar
0 votes
1 answer
4k views

I'm getting a runtime error on an array and I'm not sure why:

The following code Compiled but gave me an error (credit.c:21:7: runtime error: index 15 out of bounds for type 'int [15]') on the last line included while running: int m; int r; int counter; int ...
Chaim Tzvi Kalish's user avatar
1 vote
1 answer
37 views

Passing SQL values into arrays

I'm designing a budgeting website for the final project. One of the features that I want to implement is to be able to track how much money you've spent for each item category. The SQL command that I'...
neetdays's user avatar
0 votes
1 answer
58 views

pset vigenere skipped over if statement

for (int i = 0, j = strlen(s), k = 0; i < j; i++, k++) { if (isalpha(s[i])) { if (isupper(s[i])) { if (argv[1][k] ...
Knovolt's user avatar
0 votes
3 answers
203 views

pset2 vigenere shifting characters by the same

for (int i = 0, j = strlen(s), k = 0; i < j; i++, k++) { if (isalpha(s[i])) { if (isupper(s[i])) { if (argv[1][k] != '\0') { printf("%...
Knovolt's user avatar
0 votes
1 answer
28 views

pset7: why do we need [0] in from of list? (e.g. someData[0]['dic']?)

Just completed pset7, gosh it was a long one, took a month! Am curious as to why we need to have a [0] in front of the list to get the "pure" data? For instance, when we get back a list while ...
nvs0000's user avatar
  • 179