Smita
Can anyone explain
\Device\NUL
\Device\NUL
https://t.me/programminginc/283193
NagaRaju
I'm working on files concept in C++ in my project. First I have tried to read a complete line from the console(i.e. any data user types in one line ) using getline() and It was successfull. Now I want to read multiple lines(like paragraphs) from the console. I don't know how to read such big content from the console. If you know please help me.
MR
Please do anyone have any c++ programming whatapp group chat
NagaRaju
you can use while or for cycle
It need lines limit before user enters lines for (int line = 0; line <= maxline + 1; line++) { // writing to file } But I don't want to tell the lines limit. Untill I press ESC key whatever I write on console need to be stored in the file.
NagaRaju
Maybe using conio or ncurses stuff ?
You mean getchar() or getch() ?
\Device\NUL
You mean getchar() or getch() ?
I dunno, cuz i haven't try input ESC char but ESC is listed on ASCII char table. Maybe doing loop while cin.get isn't returning ESC char ?
\Device\NUL
Else, you gonna need tui stuff
NagaRaju
Else, you gonna need tui stuff
Can you say what is tui please ?
\Device\NUL
Can you say what is tui please ?
Text User Interface, cmiiw
\Device\NUL
It use conio on windows/dos or ncurses on *nix
NagaRaju
\Device\NUL
Can you name those functions ?
It should be getc() but i never get into TUI programming, i just assume it
J
How to use VS or VS code
If it's VSCode, just download it and use it as a text editor. For C++ features, it will already have intellisense and other stuffs pre installed or you can install them from market place.
CALVIN
How to take input from the user on vectors with out declaring the size ?
Anonymous
/* When i=2 , j=0 what will be the Output? In my logic it will go switch(1) means case 1:() which is empty so it should go to default: (1+3)= 4 but on the output I am getting 3 why? Can you please explain it? */ #include <stdio.h> main() { int i, j, x = 0; for (i = 0; i < 5; ++i) for (j = 0; j < i; ++j) { switch (i + j - 1) { case -1: case 0: x += 1; break; case 1: case 2: case 3: x += 2; break; default: x += 3; break; } printf("%d\n", x); } printf("\nx = %d", x); } /* Output: 1 3 5 7 9 12 14 17 20 23 x = 23Press any key to continue . . . */
Anonymous
use break
where? after default?
S__R
where? after default?
if no case match then it goes to the default
Anonymous
if no case match then it goes to the default
yes but my qus is When i=2 , j=0 what will be the Output? In my logic it will go switch(1) means case 1:() which is empty so it should go to default: (1+3)= 4 but on the output I am getting 3 why? Can you please explain it?
̽̀𝐀𝐫𝐤𝐚
it executes case 1 2 3 and then breaks
̽̀𝐀𝐫𝐤𝐚
yeah fall through situation
Anonymous
case 1 does not use break so your case 2 start run it also does not uses break then case3 then your use break so it will not go to the default
I have another confusion here I can see when i=4 , j=1 , switch (4+1-1)=4, ( case 4: ) which is not present on the code. So now it should go to default: (5+3)=8 But on the output I am getting 7 why?
CALVIN
maybe while loop
Please help me with a single line of code........ YouTube failed to help me in this
Anonymous
if you dont mind can you write step by step?
Anonymous
I am getting wrong output tracing.
S__R
if you dont mind can you write step by step?
why not use the debugger to see the actual execution
S__R
I dont know how to use it.
https://pythontutor.com/ then try this
J
I have another confusion here I can see when i=4 , j=1 , switch (4+1-1)=4, ( case 4: ) which is not present on the code. So now it should go to default: (5+3)=8 But on the output I am getting 7 why?
That's simple. Earlier we got 3. 4. Loop 1 i=3,x=3 Loop 2 j = 0 case 2,(Since i + j - 1 is 3 + 0 - 1 = 2) Fall through to case 3 x = x + 2 => 3 + 2 = 5 break print x=5 Loop 2 j = 1 case 3: (Since i + j - 1 is 3 + 1 - 1 = 3) x += 2 => x = 5 + 2 = 7 break print x= 7 Hence the 7
J
Why don't you debug it (Using printf or a debugger?)
Anonymous
Why it does'nt work char *a = "abc"; char *b = "def"; a[0] = b[0]; Or *(a+0) = 'A'; what's wrong with pointer
Anonymous
Riccardo
Why it does'nt work char *a = "abc"; char *b = "def"; a[0] = b[0]; Or *(a+0) = 'A'; what's wrong with pointer
te problem is that a string literal ("...") is a char const *, non a char *, thus you cannot modify it
Riccardo
you'll have to decalre it like char string[] = "..."; so that it will be copied to a modifiable area of memory
Anonymous
https://pythontutor.com/ then try this
Really really appreciated this thanks a lot! You helped me very well.
Riccardo
Yes , i know that , is there any way? (For pointer)
why can't you declare it as an array?
Riccardo
the other option is to use malloc
Anonymous
why can't you declare it as an array?
Because it's in function . char* strcpy(char* destination, const char* source); Some functions like strcpy , how do it with pointer
Riccardo
then simply don't pass a string literal as first argument
Riccardo
no metter if you declare it char *, a string literal will still be const. But it's not a problem of the function, it's the variable that is declared wrongly
Bobur
Hello everyone how could I find the courses online from C/C++
Abhishek
Hello everyone how could I find the courses online from C/C++
Here could can find some C based system programming courses and projects. Www.csepracticals.com
Midorima
Hello can someone here know C#? can someone help me from database , in table 1 info ID, transfer to Table 2, using textbox input in visual studio, thanksss
klimi
What do you think?
Mahdi
🥲 yeah there are 15315
klimi
Um sure? Buy one?
Manas
Anyone have Software Engineering Indian University Notes?
shreyas
.
Anonymous
how to make a mp3 player in C++?
Anonymous
with GUI
I use Arch
with GUI
You can use Qt as GUI framework. It can also provide you some audio stuff but I don't sure if it will be enough for your project
Pavel
As far as I remember mp3 is some either propietary or patented format, so it requires some research in addition to finding library/code
Anonymous
I think Qt will work for me?
I use Arch
Check it out
Anonymous
yup!
Anonymous
No
Anonymous
Why??