Ishikawa
why will i want to modify shell environments for that?
Suka
why will i want to modify shell environments for that?
hmm so what is system(echo $var) then?
?
Use Msys2 instead of mingw it has gcc 10 and more libs and programs
can someone tell me how can i install the latest version of gcc which is 10(as far as i know) on windows currently i use tdm-gcc
Ishikawa
no media allowed? 😒
?
Use WSL2
thank yu very much
Ishikawa
can someone tell me how can i install the latest version of gcc which is 10(as far as i know) on windows currently i use tdm-gcc
#include<iostream> using namespace std; int main() { string var ="Hello"; system("echo $var"); //required to print Hello but doesn't }
?
thats a system call right ??
Pavel
#include<iostream> using namespace std; int main() { string var ="Hello"; system("echo $var"); //required to print Hello but doesn't }
It doesn't work like that in C/C++. You need to use sprintf or some other string formatting to put your variable value into a string (if that is your problem)
Pavel
I can only guess, because "of course I doesn't work" is not a very helpful description of the problem
Ishikawa
please elaborate
Ishikawa
Pavel
please elaborate
"echo $var" is "echo $var" $var is not a variable placeholder in C/C++
Pavel
Do you have a solution. any way it can be done. you get what I'm trying to do,right?
No, I don't really get it. I mean, if you need to format a string you can use sprintf or Google "how to format string in C" Or you can set var as a env variable if that is what you want. Then it would be "echo %var%"
Pavel
You also shown the code but I don't know what it has outputted
Pavel
Maybe the string formatting is not the only problem
Ishikawa
Formatting isn't the problem bro. Its just that 'echo' system command can't access variable defined in main.
Pavel
There's no such feature in C as far as I know it
Ishikawa
Of course it can't, why it should
So is there any way it can be accomplished
Ishikawa
I just ducking forgot😞
Pavel
I did it once, I swear
Ok, if you find out how please share it, because it could be very helpful to know
Alex
ok
Anonymous
is strlen working in kernel ?
Alex
in Linux kernel yes
Anonymous
ok ,I will try .
Suka
#include<iostream> using namespace std; int main() { string var ="Hello"; system("echo $var"); //required to print Hello but doesn't }
do you mean something like this? kenzanin@artix|~/tmp/gcc ) tcc -run modify.c VAR01 1001 [kenzanin@artix gcc]$ echo $VAR01 1001
Harsh
Can anyone point to a good resource of debugging C/C++ with VSCode and GDB? I tried searching but I get confused everytime
Alex
is strlen working in kernel ?
https://www.kernel.org/doc/htmldocs/kernel-api/API-strlen.html
Harsh
try use xmake. its more convenience. for me hehe
But I'm specifically looking for GDB😅
Suka
But I'm specifically looking for GDB😅
have u try ms-vscode.cpptools?
Harsh
have u try ms-vscode.cpptools?
I have everything, need to learn how to use😂
Suka
I have everything, need to learn how to use😂
create project folder (empty folder) open using open folder create some c/cpp file hit the run button (side bar) press run and debug button select gcc/lldb (iam using linux gcc) select compiler n done dont forget to place some breakpoint in ur code. and i guess youtube have many tutorial for this? goodluck
Suka
using xmake == less step hehe
Suka
GDB as something like set x=1 commands also right?
you mean set <var>=<value>?
Kaan
Hi I just startet to C language. I know intermediate level java. Can anybody advice me a tutorial or book. If it is complicated and not very beginner friendly it is great for me because I know the fundemantals of programing.
Gc3kla
Question Mark, a surveyor has been tasked with providing measurements of a circular piece of land. This will enable a programmer to write a program for the owner that will subdivide the farm into pieces of land for different farming activities intended to be carried out on the land. Arising from the results Mark obtains, write a well documented C program that finds the area and circumference of the piece of land. Provide (a) An algorithm of the program (b) A flowchart illustrating the solution to the program (c) The C program that can implement this task.
Gc3kla
Please help
Gc3kla
The main part of the question reads, "write a well documented C program that finds the area and circumference of the piece of land"
Kaan
Will program get input from user?
Gc3kla
Yeah
Al
dunno I still don’t see a question mark underlying the question ..
Gc3kla
Please allow me to send a screenshot of how the question reads in the paper admin please.
Al
plus if you did it one time ... doing it again wont be a problem at all
Dima
screenshots are not allowed, use pastebin or hastebin
Al
if i recall correctly, even asking for homework is not really allowed... isn’t it?
Gc3kla
Well it was an exam, already done just trying to access tricks that I can use next time.
Gc3kla
Here is how I did it👇
Gc3kla
#include<studio.h> #define PI 3.142 int main() { float r, c, A; printf("\nEnter radius"); scanf("%f",&t); c=PI *2*r; A=PI*r*r; printf("circumference =%f\n Area=%f\n", c, A); return 0; }
Gc3kla
That's how I did it, I just was asking for more tricks I could go about it from people with more experience, is that wrong?
Al
t is not declared ... it wont compile
Gc3kla
Ooh sorry , That should be r
Gc3kla
#include<studio.h> #define PI 3.142 int main() { float r, c, A; printf("\nEnter radius"); scanf("%f",&r); c=PI *2*r; A=PI*r*r; printf("circumference =%f\n Area=%f\n", c, A); return 0; }
Al
yeh
Al
i would include math for a more precise definition of Pi
Gc3kla
i would include math for a more precise definition of Pi
Okay, but I only used the word PI because we always call that constant, used in calculations involving circles and curves, pi.
Gc3kla
Good night all. I am from Kenya.