Mr.
Nice, tks!!!
Burak
https://paste.ofcode.org/tXMw8bFPPhurKtrZMdAXLc
Burak
Could someone explain why it gives diffrent results?
Anonymous
In case of char arrays in c++, why I can't do this to copy char arrays. a=b; Say a and b are two char arrays
In nutshell, when compiling, the compiler understands an array-construction "type name[size]" to have a named value called 'name' which consists of the following information: 1) Address of the first element in the array, which is a const pointer 2) Type of elements of the array 3) Length of the array So we can't change the base address of an array because it is the const pointer. If you want to copy elements of one array to another, you should use memcpy or strncpy (for char string) or just write simple for-loop algorithm. If you want to copy address of array you should use type* pname = 'The array's name'
Captain
Could someone explain why it gives diffrent results?
In the first one you are passing the variable by reference i.e. the variable alias. Whatever the function makes changes to it, they will get reflected to original variable.PS this one is lvalue reference. But that's not the case with pass by value, you are just passing the copy of original variable, whatever changes are made would only reflect to the copy which will get destructed as soon as the function is done executing i.e. it will go out of scope. Hope this helps.
Bojan_Krdemn
Hi! Can you explain what's wrong. I defined a struct in .h file. '''private: struct stu{param ; param; }; ''' But i don't know how to access the struct in cpp file. Cpp file sees all the functions from h but not the struct. When I try '''struct stu name''' it gives an error and all other combinations ( possible ways of defining struct in cpp referencing the struct from header don't work)
Suka
case '+': and so on. cmiiw
Suka
for scan/input float data type i believe u need %f not %d?
Suka
np. goodluck
Suka
nice
Kishan
anyone doing facebook hacker cup?
Anonymous
like double volume = 4.0/3.0 * pi * r * r * r;
Anonymous
First of all, you need to include <stdio.h> for standard input/output, not <stdlib.h>
Kishan
yup, you have to include stdio.h
Anonymous
Change scanf("%c",&d) to scanf(" %c", &d)
Suka
there's no easy explanation than this. http://sekrit.de/webdocs/c/beginners-guide-away-from-scanf.html goodluck
Anonymous
The space before the format specifier asks scanf to consume any <space characters> like tab, enter and so on before attempting to read a char. The enter that you pressed after reading the radius is still in the input buffer and the space in front of %c asks scanf to read all of that before attempting to read a character
Anonymous
☺️
Anonymous
I defined it in the header file and tried to access from cpp
Doesnt matter where you define it. The data in private section including class definitions cannot be accessed by outside code unless granted exemption using friend declarations
Kishan
anyone solved facebook hacker cup A1 chapter 1?
Yuvanth
Guys I need a program that the input should be taken as 200 questions and gives the ouput as 20 questions random choice Please guys Can anyone help me
Yuvanth
Guys please
Yuvanth
Any one please please
Pavel
Guys I need a program that the input should be taken as 200 questions and gives the ouput as 20 questions random choice Please guys Can anyone help me
Hi, do you have trouble with writing it or you want someone to write it for you? If first, can you describe what exactly you have stuck with? If second, please read the rules
Anonymous
😊
Anonymous
Hi
mayway
Anyone have a book pdf of c++..for beginner
Anonymous
Anyone knows how to build shell?
Anonymous
A simple shell
Thomas
It's interesting, I want to build a simple shell too.
Anonymous
Anyone knows how to build shell?
Here it goes. https://brennan.io/2015/01/16/write-a-shell-in-c/ https://github.com/kamalmarhubi/shell-workshop https://danishpraka.sh/2018/01/15/write-a-shell.html
Anonymous
Hi
Ultima Filium
Hey guys
Ultima Filium
I need some help
Amine
I need some help
which kind help do you want !!!
Ultima Filium
I want to take user input in integer variable and get all the individual digits and print out the number in words so like 563 five hundred and sixty three
Amine
i think first count number of digital (in this case dived by 10 until get number of digital you have " i have code in this part" ) and then create String table for record word for each number ...
Ultima Filium
I've tried that but I'm getting the number in reverse
バレンタインがいない柴(食用不可)
Meow
Amine
why not using count for count number of dived by ten (example if counter == 2 so record one hundred in array of string ) and then i hope you to get my idea ???
Amine
I get you
what are you exactly indicate about f.. !!
Andrew
hi, is there someone that can give me some private repetitions/lessons on posix threads in C ?
Kishan
do anyone have input file of problem Bx from facebook hacker cup, if yes then please share it..
Anonymous
s
Anonymous
Can anyone help me with how to get contribute in open source, any resources?
Reeta
A lockdown has been put in place due to the pandemic. You cannot step out to buy food, however you can have food delivered to you. You can purchase any amount of food in one delivery. There is a constant delivery fee for every delivery, regardless of the amount of food purchased in the delivery. Each type of food on the menu has two properties: a price-per-meal, and freshness-time. One "meal" of food will feed you for one day; once a meal has been eaten, it cannot be eaten again. The freshness-time of a type of food is the maximum number of days for which that food can still be eaten, counting from when you received it. A freshness-time of zero means you must eat that type of food on the day of delivery. In a single delivery you can purchase as many different types of food, and as many meals of each of those types, as you have money for. The food will be delivered on the same day that you purchased it, and you will eat one of the food on the same day. Food delivery is the only way for you to receive food. Given an amount of money, which you can spend on meal prices and delivery fees, what is the maximum number of days for which you can eat food every day - counting from the day which you order? Input Each test case will begin with three integers, A, B and C, denoting the amount of money you have, the delivery fee, and the number of types of food provided by the restaurant, respectively. C lines follow, each will consist of two integers, Pi and Fi, denoting respectively the price-per-meal and freshness-time of one type of food Output Number of days you will eat food Sample Input 32 5 2 5 0 10 2 Sample Output 3
Reeta
How do I attempt this question?
Mahdi
Hi everyone I've got a header file contains a templated class And now I want to share this code with others but don't want that they be able to see implementation details. I just want they use it. How can I hide source code when it is in header file?
AJAY
#include<stdio.h> char* reverse(char*); int main() { printf("%s",reverse("computer")); } char* reverse(char *p) { int l,i; char ch; for(l=0;*(p+l)!='\0';l++); for(i=0;i<l/2;i++) { ch=*(p+i); *(p+i)=*(p+l-1-i); *(p+l-1-i)=ch; } return (p); } //Es program me output print kyu ni hora reverse hone ke baad //Anyone?
Anonymous
A lockdown has been put in place due to the pandemic. You cannot step out to buy food, however you can have food delivered to you. You can purchase any amount of food in one delivery. There is a constant delivery fee for every delivery, regardless of the amount of food purchased in the delivery. Each type of food on the menu has two properties: a price-per-meal, and freshness-time. One "meal" of food will feed you for one day; once a meal has been eaten, it cannot be eaten again. The freshness-time of a type of food is the maximum number of days for which that food can still be eaten, counting from when you received it. A freshness-time of zero means you must eat that type of food on the day of delivery. In a single delivery you can purchase as many different types of food, and as many meals of each of those types, as you have money for. The food will be delivered on the same day that you purchased it, and you will eat one of the food on the same day. Food delivery is the only way for you to receive food. Given an amount of money, which you can spend on meal prices and delivery fees, what is the maximum number of days for which you can eat food every day - counting from the day which you order? Input Each test case will begin with three integers, A, B and C, denoting the amount of money you have, the delivery fee, and the number of types of food provided by the restaurant, respectively. C lines follow, each will consist of two integers, Pi and Fi, denoting respectively the price-per-meal and freshness-time of one type of food Output Number of days you will eat food Sample Input 32 5 2 5 0 10 2 Sample Output 3
Sort the food item on Pi first and then within that list sort them based on Fi i.e iems with the same Pi should be sorted according to Fi. Use greedy programming following that
Anonymous
Hi everyone I've got a header file contains a templated class And now I want to share this code with others but don't want that they be able to see implementation details. I just want they use it. How can I hide source code when it is in header file?
You can't hide the implementation. If you know the instantiations that the clients will require beforehand, then there is a way. But with that, the client loses the ability to instantiate your template with any type of his choice
Anonymous
Anyone tell me one thing i have one issue in hash Supposed i have aaray size is 6 {3,4,3,5,6,4} so i wana map its in form of 1=0,2=0,3=2,4=2,5=1,6=1
Anonymous
Koi help nhe krayga 🥺
MᏫᎻᎯᎷᎷᎬᎠ
How do you pronounce the -> in your head? Hey guys, I am freaking out with all these symbols in Rust. I thought the book was a bit easy at first but then you get the this type of syntax. I wish the return type was like Java's. When I try to understand something I usually say it with my inner voice. In the case of the arrow I am not sure. I am really confused with other languages. Is it "for each" "return" "to"? https://redd.it/pez698 @r_rust
MᏫᎻᎯᎷᎷᎬᎠ
This is a really good question
MᏫᎻᎯᎷᎷᎬᎠ
Yeah The -> used to indicate the return type in Rust
MᏫᎻᎯᎷᎷᎬᎠ
But in C++ context We use it mostly with pointers
MᏫᎻᎯᎷᎷᎬᎠ
Not relevant to C/C++
No This is soo relavent
MᏫᎻᎯᎷᎷᎬᎠ
Every talk about Rust is so relavent to C++
klimi
Every talk about Rust is so relavent to C++
Every talk about python is so relevant to rust
MᏫᎻᎯᎷᎷᎬᎠ
Ever
Anonymous
Every talk about Rust is so relavent to C++
Not really. Just because one is considered a better version of the other it doesn't mean that every discussion is relevant. Moreover just saying "it is relevant" without saying why a discussion on what goes in your head when you use arrow operator in rust is relevant to C++ just doesn't seem right. And so if discussion on every language is relevant why don't you go ahead and try asking Rust questions in a stackoverflow group for C++?
Anonymous
Because stackoverflow is for technical stuff only The group here is more open I recall that you can post programming memes here Is that allowed in stackoverflow
Ok so your idea of saying "Discussions on rust is relevant" is because we allow programming memes here (I don't agree with that decision anyway)? So in your words we should let people discuss golang, D, Algol, Smalltalk as well here as they may all be considered relevant to C/C++
MᏫᎻᎯᎷᎷᎬᎠ
Ok so your idea of saying "Discussions on rust is relevant" is because we allow programming memes here (I don't agree with that decision anyway)? So in your words we should let people discuss golang, D, Algol, Smalltalk as well here as they may all be considered relevant to C/C++
Nah I don't mean every C-like language should be discussed aggressively, but unless it's a rust yes, it should be Because Rust has a lot of topics that are similar to C++ to address and talk about Look for some chat above, you'll see even a debates about it
MᏫᎻᎯᎷᎷᎬᎠ
And by the way My talk is relavent to C++, not because I've mentioned Rust in it
MᏫᎻᎯᎷᎷᎬᎠ
But in C++ context We use it mostly with pointers
It was just like How does your inner voice pronounces the -> in C++?