Talula
#include <stdio.h>
#include <string.h>
int main()
{
char str1[10]= "awesome";
char str2[10];
char str3[10];
strcpy(str2, str1);
strcpy(str3, "well");
puts(str2);
puts(str3);
return 0;
}
Ritu Raj
Anonymous
Use strncpy not strcpy
Ritu Raj
Ritu Raj
One is limited 😇😇
Anonymous
One is limited 😇😇
One is horribly insecure and should be avoided just to make good habits
Anonymous
Ritu Raj
Ritu Raj
I'm wondering why the second approach doesn't work. It seems natural that it should (it works with other data types)? Could someone explain me the logic behind this?
Mihail
Anonymous
When you have an array like char string[4]
string is a pointer to the first element of the array So if the second did work you would be overwriting a pointer somewhere not the value it points to
Anonymous
- Raymond
Can someone tell me whi should I chose if over switch? Which one is better to use in most cases?
- Raymond
Well I just found one answer; you can't use double with switch
olli
switch - case is more limited than if statements, but there is no general rule.
- Raymond
Then why would you even have switch, if you can already do everything needed and even more in if statements ?
Ανδρέας 🇮🇹
Ανδρέας 🇮🇹
Ritu Raj
Omkar
Hi
- Raymond
Quick question
- Raymond
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
double BTCPrice = 10000.111;
int main()
{
cout << BTCPrice << endl;
cin.get();
}
- Raymond
Why does this show the result as 10000.1 ?
- Raymond
and not 10000.111 ?
olli
Why does this show the result as 10000.1 ?
because defaultfloat is probably set and the precision is set to 6, so there are 5 digits before and one after the decimal point
if you want a fixed number of digits after the decimal point you should std::fixed as formatting
- Raymond
👍
Anonymous
Pls solve questions 1
Anonymous
Anonymous
Read the rules, we are here to help you, not for doing your homework
Anonymous
Show us where you are facing the problem
Anonymous
Anonymous
Can any one help me with gtk in c
Anonymous
I don't know how to change the size of fonts in gtk
Anonymous
I want to increase the size of fonts in the entry
Anonymous
I am new with gtk so I don't know much off it
Anonymous
Ok
Anonymous
Hi
Anonymous
klimi
Hi
Anonymous
Wt??
Jussi
Does anyone here know, why GPT partition GUID changes when I move the partitioned drive between PCs? I mean if I format a USB stick and plug it into another machine, the GPT GUIDs are different
Jussi
Sorry, it is an offtopic question
Anonymous
GUIDs are assigned once first time an OS encounters the disk, it doesn't changefor that specific system but will be different for different computers!
Anonymous
change for*
Anonymous
Hello guys
Anonymous
Lets say we have this array: array[]={1,2,3,4,5}
How can we display this array like this: (1+2+3+4+5)
Anonymous
Ok sir
klimi
Jussi
Jussi
I mean in the GPT partition table on the disk
Jussi
Why cant the system just use that one ffs
klimi
I don't think it changes tbh
Jussi
It does
Jussi
At least the corresponding UEFI GUID changes
Anonymous
Just print it
I did this but the output is not like I expected
Anonymous
It suppose to be (2+7+6+9+8)
klimi
But you don't print the parentheses
klimi
You need to have one before that for loop and one after forloop
klimi
And you have to check for the last character if it is last so you don't print +
Niveth Saran
Guys? Which IDE of C++ would you prefer for Competitive Coding?
BinaryByter
honestly?
BinaryByter
probably vim
klimi
BinaryByter
it kinda is
klimi
Dima
> vim
> ide
Dima
Otumian
Hey.. how are you..
Otumian
It will be vac very soon.. I would like a suggestion on some c or c++ projects to work.. preferably c++
Mihail
klimi
Otumian
Oh not to forget, there must be adequate resources on it..
Pratik
Hey guys do u have syntaxes of
cpp and java
It's imp
Anonymous
Anonymous
Mat