hi,is it normal if i have difficulties understanding some of theses concepts?(this one wasn't hard but i've been having a hard time on these last videos i watched)
It may be hard at first, but if you keep trying with programs using these concepts it'll eventually click. The main difference between someone who'll succeed learning to code and someone how willing you are to learn no matter how tough it gets.
So i'm pretty sure using !foods.empty in the for loop like that, will make it out of bounds when entering 5 elements. So I changed this, and i'm sure its better, nested inside the for loop add the !foods thing in a if statement. Like this. for(int i = 0; i < size; i++){ if(!foods[i].empty()){ std::cout
Do we really have to make a new variable "food" to call out the input value? Can't we display the value thru cout and put the variable "foods" to display the input value? And why exactly we divide the getsize foods[5] to getsize foods [0] where as the second one has no value?
arrgh but getsize foods [0] does have a value of 5 (or what number you have in the line above), and sizeof(foods) has 5 times that or 120 in this case.
Oh back again after doing something else, if I change the code to string foods[6]; // int size = sizeof(foods)/sizeof(foods[0]); int size = (sizeof(foods)/sizeof(foods[0]))-1; it is alright and does not show Segmentation error
#include
int main()
{
std::string foods[5];
int size = sizeof(foods)/sizeof(foods[0]);
std::string temp;
for(int i = 0; i < size; i++){
std::cout
hi,is it normal if i have difficulties understanding some of theses concepts?(this one wasn't hard but i've been having a hard time on these last videos i watched)
I can help if your still stuck
It may be hard at first, but if you keep trying with programs using these concepts it'll eventually click. The main difference between someone who'll succeed learning to code and someone how willing you are to learn no matter how tough it gets.
The same sitution Bro
@@crogat2298 goddamn bro. Whole motivational speech🤣
Good Video. Let's defeat the YT algorithm.
So i'm pretty sure using !foods.empty in the for loop like that, will make it out of bounds when entering 5 elements. So I changed this, and i'm sure its better, nested inside the for loop add the !foods thing in a if statement. Like this.
for(int i = 0; i < size; i++){
if(!foods[i].empty()){
std::cout
Hmmm, it is a Logic condition, so I don't think you would have anything to worry about, Logic doesn't run out of bounds, as far as I know
Do we really have to make a new variable "food" to call out the input value? Can't we display the value thru cout and put the variable "foods" to display the input value?
And why exactly we divide the getsize foods[5] to getsize foods [0] where as the second one has no value?
arrgh but getsize foods [0] does have a value of 5 (or what number you have in the line above), and sizeof(foods) has 5 times that or 120 in this case.
Nice
what do you mean 5 is small??
I get a "Segmentation error", but if I use 'q' before finishing the 5 foods the error does not show
Oh back again after doing something else, if I change the code to
string foods[6];
// int size = sizeof(foods)/sizeof(foods[0]);
int size = (sizeof(foods)/sizeof(foods[0]))-1;
it is alright and does not show Segmentation error
#include
using namespace std;
int main()
{
string foods[5];
string temp;
for (int i = 0; i < size(foods); i++)
{
cout
anyone willing to share their contact info .i am new to coding anyone new wanna help each other out anyone
definitely do you have a discord
for (int i = 0; !foods[i].empty(); i++) - I've never thought about doing this check before, expanding my Thinker