حسام
Hi @Hosam_47 i read your code and also the problem it was trying to solve. Then I tried creating separate functions to be able to get what you wanted. But then it occurred to me that in doing so I am limiting myself to the c++ language. This is because a class can do it better be just executing it all. Well I also learnt a lot from your code. I just tried to do it the OOP way and send it to you so you can see. Thumbs up, would be waiting to hear from you.
Being the total beginner that I am Hearing someone learned something from my code is a huge achievement for me, thank you Udoh But the problem is that because I’m still a noob I actually don’t know a thing about classes, planning to but atm I’m not even decent in programming I’m still learning the basics. Your code looks really good btw. Cheers.
Papa
Hey! Can anyone tell me why we use protected in case of private and public:
Chandresh
Hey! Can anyone tell me why we use protected in case of private and public:
Public method is accessible by all class whether in same package or in different package....private method is only accessible to the class where it declared.we can't access it in the same package's other class...
Chandresh
While protected method is accessible to any class in different package... which extends the class where protected methos is declared..so protected method is visible to other class only if the class extends the protected method's declaration class.
Papa
Ok thanks
Andrey
/get
Andrey
/get best
Jessy
#cppbookguide
Thank you
Diego
Thank you☺
I still recommend starting with C++ though, but as that person said, focusing on the procedural aspect of the language
Diego
Focus on C++ for now, and you'll appreciate the differences in time
Diego
You'll thank me (probably)
حسام
Good evening everyone. I’m stuck with this problem for two days and it’s really simple but I’m still learning the basics so excuse me. I’m supposed to creat 3 functions the first one is supposed to be to enter an array of 7 string and the second one is to check whether the strings in the array are palindrome and the third is to only print the palindrome string. I could use any help tbh I’ve got the inputting correct and the outputting is half correct because it’ll print the whole array not only the palindrome ones.
حسام
Here’s my code for reference
حسام
#include <iostream> using namespace std; #include<string.h> void inputstring(string arraystr[7]); void palindrome(string str[7],string result); void Printstring(string array[7]); int main() { string array1[7]; string r; inputstring(array1); palindrome(array1,r); Printstring(array1); } void inputstring(string arraystr[7) { int i; string str; for (i = 0; i < 7; i++) { cout << "enter the string number " << i + 1 << ": \n"; cin >> arraystr[i]; } }; void palindrome(string str[7], string result) { string str1, revstr; if (str1 != revstr) { result = false; } else result = true; }; void Printstring(string array[7]) { cout << "the palindrome strings are: \n"; for (int i = 0; i < 7; i++) cout << array[i] << " "; }
حسام
man c++ is hard or am I just dumb
Eturnus
man c++ is hard or am I just dumb
just clear basic concept it will be easy for you
Vala
#include <iostream> using namespace std; #include<string.h> void inputstring(string arraystr[7]); void palindrome(string str[7],string result); void Printstring(string array[7]); int main() { string array1[7]; string r; inputstring(array1); palindrome(array1,r); Printstring(array1); } void inputstring(string arraystr[7) { int i; string str; for (i = 0; i < 7; i++) { cout << "enter the string number " << i + 1 << ": \n"; cin >> arraystr[i]; } }; void palindrome(string str[7], string result) { string str1, revstr; if (str1 != revstr) { result = false; } else result = true; }; void Printstring(string array[7]) { cout << "the palindrome strings are: \n"; for (int i = 0; i < 7; i++) cout << array[i] << " "; }
Eturnus
remove semicolon in 7th line from below
Eturnus
also remove in 17th line from below
Eturnus
there us an error in result = false; <=this line
Eturnus
11 th line from below
Eturnus
there us an error in result = false; <=this line
i am unable to solve that error 😅 its because i am also a new programmer in c++ so i apologise.
Anonymous
Hi. How to web programming with pure c?
Anonymous
CGI
Can you send me reference?
Anonymous
Why do you need C to do web programming?
Anonymous
http://jkorpela.fi/forms/cgic.html
Lion
courageous approach
J
man c++ is hard or am I just dumb
@Hosam_47 my advice for you to learn c++ quickly will be to go learn the basics about the program. Learn the fundamentals. When you're sure you call do the basic like simple arithmetic, then go on to complex. And make sure your learning curve always involve exercises. Then after learning the complex, then go on to system analysis and all that. But first get the basics and fundamentals right. Jumping from concepts to concepts will get you confused. Learn the basics first
Shinchan_OP
Shinchan_OP
C is not a lang for you
Lion
using CGI is quite simple though, for fun. it's basically 'stdio as a port 80 service'.
Talula
Hi. How to web programming with pure c?
Client Side or Server Side?
Talula
Hi. How to web programming with pure c?
For Server Side you could use C# instead of Pure C, but if you want to use Pure C, use CGI... http://jkorpela.fi/forms/cgic.html This tells you how to do that... you can do it but it's going to be real pain.
Anonymous
you must go for JS
No No No! Just C😂
Anonymous
Hi. How to web programming with pure c?
HI, Only C? Why not C++ 😁: https://github.com/an-tao/drogon
Janko Ⓥ
Hi. How to web programming with pure c?
The Web wasn't designed that way
Anonymous
death :)
🥺😂
Anonymous
use Rust instead
What do you think about nim? Nim-lang.org/
Nameful
What do you think about nim? Nim-lang.org/
I haven't really used it so I don't know
Anonymous
lol
HeyMilkshake - 🇵🇹
Anonymous
When you're using C APIs, for Memory Management and prevent nasty Wrappers on The API's consider to using this: https://www.boost.org/doc/libs/1_75_0/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_ALL.html
HeyMilkshake - 🇵🇹
Cesco
sorry
Cesco
srand(time(NULL)); n=rand()%2; if(n==1){cout<<"testa";} else{cout<<"croce";}}} i have all the time "croce", i can't understand why.
tim
have you tried printing the result of rand()?
tim
before you apply mod
Anonymous
No thanks I'll try
Try this: http://ix.io/2Vig
Cesco
It's random ... who knows? 😂
Yes but the probability after 20 times is 1/2^20 i mean maybe I'm just unlucky
Ludovic 'Archivist'
Or that the rand function is pure trash which may be the truth of the situation
Anonymous
Yes but the probability after 20 times is 1/2^20 i mean maybe I'm just unlucky
As @QNeko said, rand() function is not good enough, try std::random: http://ix.io/2Vik
Anonymous
Hey guys can I ask a question?
Andrew
yes
Anonymous
There's something wrong with my code and I'm pretty sure I missed something
Anonymous
#include <iostream> using namespace std; int main() { int year; int month; int perYear=12; double yearIn_decimal; cout<<"Enter your age in years"<<"\n"; cin>>year; cout<<"Enter how many months it's been since your date of birth"<<"\n"; cin>>month; for(int x=0;month>=0;x++) { if(x=0){ cout<<"Your total age is"<<"\n"<<year<<endl; } else if(x>0) { yearIn_decimal=year+month/12; cout<<"Your age in precision is"<<"\n"<<yearIn_decimal<<endl; } return 0; } }
Anonymous
I think it's got something to do the for loop I used
Anonymous
Anonymous
Multiple things
The code runs but not the way i want it to
Vitaliy ◀️TriΔng3l▶️
ah, no, the loop wouldn't be infinite here, but it's pretty pointless still
Vitaliy ◀️TriΔng3l▶️
The code runs but not the way i want it to
Try to read every statement like if you were a compiler, and trying to understand what each operator means
Otumian
if(x=0)
Anonymous
if(x=0)
Yeah if we assign a value zero right?
Vitaliy ◀️TriΔng3l▶️
What do you mean?
As a thought experiment, can you express your loop in terms of while rather than for? And try to execute it in your mind
Otumian
Anonymous
==
I tried