4,449 questions
-2
votes
2
answers
115
views
How to read multiple lines into variables with a single read-command?
I need to read a three-line text like:
4
10
foo
into three variables: num1, num2, name.
I tried IFS=$'\n' read num1 num2 name <<< $data, but that only initializes the num1, leaving the rest ...
0
votes
2
answers
81
views
execute lines of text from a txt file in native batch script [duplicate]
I have a text file, and I want to read in the entire file to a variable and then execute it. I then want to clear the variable contents and the file contents.
for /f "delims=" %%A in ('type ...
2
votes
1
answer
43
views
Error: Invalid dot name structure assignment because the structure array is empty
I'm having this error but I don't understand why. I'm creating a structure of size 3x4x4 with 6 fields within loops. Then, I would like to create two more fields for the whole structure. How can I do ...
-3
votes
3
answers
46
views
What is the difference when assigning an object like a LinkedList to a variable versus an array?
I was working on this problem from HackerRank trying to insert an element at the tail of a linked list and I have to return the head of the node.
def insertNodeAtTail(head, data):
if head is None:...
13
votes
5
answers
2k
views
How Does the Left-Hand Side (LHS) of an Assignment Evaluate in C?
I’m working on understanding pointers in C by breaking down the language into three key areas: syntax, semantics, and idioms.
To grasp pointers, I’ve been focusing on fundamental concepts:
what’s an ...
3
votes
1
answer
113
views
PHP variable as reference
I'm confused about the concept of variable in PHP.
As far as I know, a variable in PHP has a name ($p) and a value ('Carlo').
$p has an associated entry in symbol table, such an entry actually points ...
0
votes
0
answers
48
views
Read CSVs and assign to variable name using for loop in R [duplicate]
I downloaded 11 years of reports from a government website and they each came in their own folder in a parent directory. The name of each subfolder is the year, and the file inside is named the same ...
0
votes
1
answer
51
views
How would i make, access, and modify a flexible list in batch
I have a batch file that checks if a previously compiled exe file exists. If not, it will recompile, otherwise it will check if any files have been modified since the creation of the exe file. If ...
0
votes
0
answers
27
views
Referring to the variable being assigned to on the right side of the assignment operator
Sometimes it may be necessary (yes, likely against best practices) to deal with nested objects, such as lists, which can require multi-level indexation. I am curious of the following:
1. In Python, is ...
2
votes
1
answer
48
views
How to read a CSV or Excel file of parameter names and values and assign them in MATLAB workspace
I have a Excel file with names of variables and their associated values as columns ash shown below:
I would like to use them in my Simulink model as inputs, therefore I need them to load as variables ...
1
vote
3
answers
90
views
How do I guarantee the rust compiler that a certain variable will get initialized in a for loop?
This question is in relation to the question asked here: How to declare a variable but not assign it?
My problem is slightly different. MRE:
let var: MyGenericType;
for value in ...
-8
votes
2
answers
96
views
Why does i += ++i result in 1 in Java? [duplicate]
I was learning Java. I am facing a problem with the following expression:
int i = 0;
i += ++i;
System.out.println(i);
It says the output is 1.
If we rewrite it like this:
i = i + ++i;
When increment ...
0
votes
2
answers
112
views
My C code works fine but crashes right before the end (0xC0000374)
So I'm learning to code (in C) for a few months now and I'm focusing here on memory allocation.
My code is very simple, everything works, and yet at the end, it doesn't return a 0 but instead I get a -...
0
votes
1
answer
56
views
Python Pulp LP leaving rooms unassigned and penalties/constraints not preventing that
I am having difficulty getting all classrooms to be assigned to a class for a room assignment problem. I am using a grid calculated based on class capacity & room capacity (values 0-1). ...
0
votes
0
answers
34
views
Passing Nginx Rewrite To PHP
I've created the following Nginx Rewrite:
rewrite ^/([0-9A-Za-z]*)$ /index.php?redirect_reference=$1;
Then in my index.php I have:
<?php
echo $redirect_reference . "\r\n";
...