I want to print data like this :
FirstName FamilyName (33 characters), Tel: xxxxxxxxxx, Age: xx, Level: xx, Salary: xxxxx.xx
For example
John Dilbert Tel: 6135202600, Age: 58, Level: 13, Salary: 450.34
Jane Smith Tel: 6135202600, Age: 47, Level: 10, Salary: 133450.00
Main problem am facing is how to put Tel: one before the other . Also how to format the floating salary such that decimal comes one below the other.
Currently my output look like this :
John Dilbert Tel: 6135202600, Age: 58, Level: 13, Salary: 450.34
Jane Smith Tel: 6135202600, Age: 47, Level: 10, Salary: 133450.00
Code :
void printData(struct person currentPerson){
printf("%s %-33sTel: %10s",currentPerson.firstName,currentPerson.familyName,currentPerson.telephone);
}
void printStudent(struct Student currentStudent){
printf("GPA:%3d, Courses:%3d, Tuition: %5f\n",currentStudent.GPA,currentStudent.coursesCount,currentStudent.tuitionFees);
}
In main:
printData(person[i]);
printf(", ");
printStudent(person[i].student);
But still result is wrong. Why ? Please help
If you want to control the width of your data, then you could use the width sub-specifiers in the printf format string. Eg. :
printf("%5d", 2);
Related
So, I'm helping out someone, and I'm trying to extract only the name of the cancer in the column, without including "Deaths -".
In Column A, the entries all have this pattern, each string below being in it's own separate row...
Deaths - Prostate cancer - Sex: Both - Age: Age-standardized (Rate)
Deaths - Breast cancer - Sex: Both - Age: Age-standardized (Rate)
Deaths - Testicular cancer - Sex: Both - Age: Age-standardized (Rate)
Deaths - Non-melanoma cancer - Sex: Both - Age: Age-standardized (Rate)
Deaths - Tracheal, bronchus, and lung cancer - Sex: Both - Age: Age-standardized (Rate)
I've been able to extract the name of the cancer, including removing the word "cancer" with this LEFT and SEARCH formula below...
=LEFT(A2, SEARCH("cancer", A2)-1)
Resulting in the following...
Deaths - Breast
Deaths - Testicular
Deaths - Non-melanoma
Deaths - Tracheal, bronchus, and lung
But, I can't seem to combine REGEXREPLACE with LEFT and SEARCH in one formula to also take out "Deaths" and the - (dash), leaving only the name of the cancer.
So, the desired result is below...
Breast
Testicular
Non-melanoma
Tracheal, bronchus, and lung
Thanks for any help you can provide.
try simple:
=INDEX(IFNA(REGEXEXTRACT(A1:A6, "- (.+) cancer")))
I have a YAML document that contains an array. I would like to conditionally add properties to the elements of that array using yq version 4 from mikefarah.
Here is a sample YAML document.
name: "My Pets"
pets:
- name: "cat"
age: 8
- name: "dog"
age: 3
- name: "mouse"
age: 1
I would like to transform this into,
name: "My Pets"
pets:
- name: "cat"
age: 8
shots: cat.upToDate
- name: "dog"
age: 3
shots: dog.upToDate
- name: "mouse"
age: 1
shots: mouse.upToDate
where we add a shots property to each element of pets. The value of shots should be whatever the name value is, dot, upToDate.
I'm trying something like this,
yq eval '.pets[] | select(.name == "cat").shots = "cat.upToDate"' test.yaml
but that produces,
name: "cat"
age: 8
shots: cat.upToDate
name: "dog"
age: 3
name: "mouse"
age: 1
I need to preserve the entire original YAML document and just insert the shots property.
This is close but missing all of the other pets.
yq eval '.pets = (.pets[] | select(.name == "cat").shots = "cats.upToDate")' test.yaml
It produces,
name: "My Pets"
pets:
name: "cat"
age: 8
shots: cats.upToDate
I'm thinking maybe we could store the name of the pet in a variable and reference that later, but v4 is brand new to me today.
I would prefer to have a one-liner so that I don't have to filter on .name. This array has less than 10 elements so I could easily hard-code the name and call yq 10 times.
Any thoughts or suggestions? Many thanks, Weldon
Use |=, e.g. like so:
yq eval '.pets[] |= (.shots = (.name + ".upToDate"))' pets.yaml
table name: muscle_groups
fields: id, name, segment_ids
data:
{"f": [], "m": [31, 32, 33, 34, 35, 36, 38, 39]}
tried many variations like:
select id, name, segment_ids->>"m"
where 5 = any(json_array_element(segment_ids->>"m")
You are looking for the contains operator #>
select *
from muscle_groups
where segment_ids #> '{"m": [5]}'
I have an array with two elements below:
if params["location"]
params["location"]["street"] =[
params["location"].delete("address1"),
params["location"].delete("address2")
].compact.join(", ")
l = ::Location.create!(street: params["location"]["street"],
city: params["location"]["city"],
state: params["location"]["state"],
zip: params["location"]["postal"],
country: params["location"]["country"])
What I am trying to do is join the two together sperated by a ", " only if address2 is an empty string/nil.
Example 1:
address1 = "56 West Gay Street"
address2 = "Apt. 211"
Actual: "56 West Gay Street, Apt.211"
Expected: "56 West Gay Street, Apt.211"
Example 2:
address1 = "56 West Gay Street"
address2 = ""
Actual: "56 West Gay Street, "
Expected: "56 West Gay Street"
The problem is that params['location']['address2'] is not empty, but an empty string. You can use present? to select only strings that are not blank.
if params['location']
street = [
params['location'].delete('address1'),
params['location'].delete('address2')
].select(&:present?).join(', ')
l = ::Location.create!(params['location'].merge('street' => street))
end
Assuming a and b are your two string:
[a,b].select(&:present?).join(", ")
On admin/structure/trigger/comment I have the following:
On admin/config/system/actions I have the following:
When I click "configure" and go to admin/config/system/actions/configure/81
Here's the text in the message textarea:
[comment:url:absolute]
Comment ID: [comment:cid]
Comment Text:
[comment:body]
Comment Author:
[comment:author]
Comment Created:
[comment:created]
This is the email I receive, notice how it is not replacing comment:cid:
https://example.com/comment/#comment-
Comment ID:
Comment Text:
This is a test comment.
Comment Author:
auser
Comment Created:
February 5, 2015 - 21:20