+ 1

If I want to create an array (in C++) of which at the beginnin I don't know its length, how can I do ? Exist a way to do that ?

10th Oct 2017, 8:12 PM
Lorenzo Zanetti
6 Answers
+ 12
In C++ array must have compile-time length. So You should use dynamic array (Dynamically Allocated Array). int size; int *arr = NULL; cin >> size; a = new int[size]; ... delete[] a; if you write: int arr[size]; where size is a variable and not a constant at compile-time it won't compile.
10th Oct 2017, 8:56 PM
Developer
+ 9
@LorenzoZanetti You're welcome. Good luck.
11th Oct 2017, 8:14 PM
Developer
+ 9
@anu I don't understand the challenge well. I mean If he wants to write an IRC server/client so there shouldn't be any problem. You write that code in server. For example you write a server program with socket programming and then listen to a port and use IRC protocol to communicate. so you have a server and you can give any services or calculation you want to the clients. I saw the challenge page and I saw some similar answers. BTW @LorenzoZanetti I apologize for putting a long answer to your question that is not related to your question. Sorry :)
12th Oct 2017, 7:35 PM
Developer
+ 1
Thanks very much !
11th Oct 2017, 12:30 PM
Lorenzo Zanetti
+ 1
@developer do not worry it's not a problem ! ;)
13th Oct 2017, 11:45 AM
Lorenzo Zanetti
0
[UNSOLVED] How to make an auto reply program for a private chat bot on IRC? https://client01.chat.mibbit.com/?url=irc%3A%2F%2Firc.root-me.org%3A6667%2Froot-me_challenge For example if we send private chat to a bot named Candy: !ep1 that bot reply two number. <number1>/<number2> how to make an auto reply of calculation result to Candy bot: calculate the square root of the number1 and multiply the result by the number2. Then round to two decimals. For example in C++: printf("%0.2f", sqrt(number1)*number2); feel free to use any programming language. i am expecting solution for this from u , as posted in Q&A soloearn today @developer
12th Oct 2017, 10:03 AM
anu
anu - avatar