Boom
Boom
printf("Enter the number of travellers\n");
scanf("%d", &person);
for (int i = 0; i < person; i++)
{
if (age[i] == 0)
{
printf("Enter the name of person %d\n", (i + 1));
scanf("%s", name[i]);
printf("%s , Enter your passport number \n", name[i]);
scanf("%llu", passport[i]);
printf("%s ,Enter your age \n", name[i]);
scanf("%d", age[i]);
}
}
Boom
printf("Enter the number of travellers\n");
scanf("%d", &person);
for (int i = 0; i < person; i++)
{
if (age[i] == 0)
{
printf("Enter the name of person %d\n", (i + 1));
scanf("%s", name[i]);
printf("%s , Enter your passport number \n", name[i]);
scanf("%llu", passport[i]);
printf("%s ,Enter your age \n", name[i]);
scanf("%d", age[i]);
}
}
In these, it works fine till enter your passport but after entering passport number program is terminated
sleepy
#include <stdio.h>
int main(){
Printf ("hello there\n");
Printf ("my name is Cyrus\n");
Printf ("i am using C programming\n");
Return 0;
}
....
Is this program correct?
Talula
Talula
\Device\NUL
\Device\NUL
sleepy
● Igor
Boom
Boom
printf("Enter the number of travellers\n");
scanf("%d", &person);
for (int i = 0; i < person; i++)
{
if (age[i] == 0)
{
printf("Enter the name of person %d\n", (i + 1));
scanf("%s", name[i]);
printf("%s , Enter your passport number \n", name[i]);
scanf("%s", passport[i]);
printf("%s ,Enter your age \n", name[i]);
scanf("%d", age[i]);
}
}
Boom
Boom
Anonymous
Missed everywhere except first scanf
conko
Or simply because puts automatically append \n at the end?
Mahsun
Anyone can speak Indian! Need your help with translation a text!
Dima
Dima
http://t.me/c_cpp_india
Mahsun
数学の恋人
I was just inspecting some C++ code and found this line,
const double PI = 2.0 * acos(0.0);
Why is it being done like this?
If it were me, I'd put the value of 20 with 21 precision level, because I remember only 20 decimal digits of pi, but max precision I believe is 15 digits so I'd stop at 15 digits
数学の恋人
but that way, anything particular about acos?
数学の恋人
I haven't investigated the acos function, but I guess it's because of it's implementation, maybe Lagrange polynomial or similar...
klimi
数学の恋人
what do you mean?
Jerry
i have a code which im trying to add the value of a number ,
such as '0' which is 48 in ascii
i want the value 0,not 48
what should i do?
klimi
Jerry
yes yes i figured it out
数学の恋人
数学の恋人
Oh btw any good library to make digital noise/sound in C++
数学の恋人
I'm not trying to play an audio file rather generate an audio file
数学の恋人
So I'll have to access the soundcard, give it the frequency, channels, blocks, etc. How can I achieve that on Windows system
Jerry
im trying to write in a array of char which i made
but im not succeeding to write in it
i did a pointer for the array i made by malloc
and p=*coded_str
and im trying to put number in it and its not working
im doing
p[i]=4 for instance
but i dont get it inside
anybody know what the problem is ?
数学の恋人
数学の恋人
Jerry
sorry im new to this sharing thing
klimi
数学の恋人
How come?
It's a const definition which means it has to be available during runtime thus gets computed during compile time
Jerry
https://www.toptal.com/developers/hastebin/raw/boruqutato
klimi
Jerry
im trying to write in the array i made its not working
\Device\NUL
Clang and GCC also optimize printf with single char, examples printf("\n"); will optimized to putchar('\n');
\Device\NUL
Iwan
\Device\NUL
Baki
Hey, what should i do if i want clear the data form the array
\Device\NUL
\Device\NUL
You can't erase memory, You could only rewrite it. That's why you can recover deleted file
Baki
memset ?
since I'm working on my college project , so in college they have not taught us memset that is why I can't use it , Is there another way to do it?
\Device\NUL
\Device\NUL
The other way is using loop, iterate and assign it to zero
Baki
This code is exiting with return 0, after printf("Would you like to proceed? (Y/N)\n");
please help
\Device\NUL
About char arrays, do you really want to initialize the first member with '0' or '\0' ?
\Device\NUL
\Device\NUL
I also prefer getchar() to get single char rather scanf()
Baki
\Device\NUL
\Device\NUL
When you initialize not full of array's member, the rest will implicitly initialized to zero
Baki
\Device\NUL
sorry, I didn't understand
scanf("blabla");
getchar();
before you inputting char to getchar(), The program will end because the newline from previous input scanf() will goes to getchar()
Baki
so i should always use getchar if i want to input single character , is that what you mean?
\Device\NUL
\Device\NUL
#include <stdio.h>
int main(void)
{
char str[255] = {0}, id[127] = {0};
scanf("%254[^\n]", str);
scanf("%126[^\n]", id);
}
\Device\NUL
The program ends but i only enter one input, Why ?
\Device\NUL
Because the newline or EOF from previous input goes to the next scanf()
\Device\NUL
The way to clear the newline or EOF from previous input is placing getchar() between those scanf()
\Device\NUL
scanf("")
getchar();
scanf("");
That getchar() will eat the newline, so it doesn't go to the next scanf
Baki
ohhh, now i get it, thank you
Baki
which library should i use for getchar()?
Baki
Baki
😭