Anonymous
/getcbook
MRT
/getcbook
Mahmoud
/getcbook
Levi
how do i take user input (scanf )in sublime text ?
%Nikita
how do i take user input (scanf )in sublime text ?
I quite don’t understand your q. If you edit your source in Sublime, then what problem with especially scanf?
%Nikita
it just ignores scanf function
Maybe you forget to save file after adding scanf?
Levi
no place to input values
%Nikita
no place to input values
Are you running ur code in terminal?
%Nikita
Idk, check u save file after adding scanf. Don’t know in sublime exactly but try ( Ctrl + S )
%Nikita
If you using gcc and scanf is in your source it must work
Levi
it shows output for printf ,but does not takes input values.
%Nikita
it shows output for printf ,but does not takes input values.
Can you send source, maybe problem is here
%Nikita
And send compile command, which you use to build your app
Levi
Can you send source, maybe problem is here
source code or photo of the cod3
%Nikita
Just in txt form, as I remember you can’t send photos here
Levi
#include<stdio.h> int main() { int n; printf("enter a number \n"); scanf("%d",n); return 0; }
Levi
i think i'll use other vs code
%Nikita
%Nikita
To take address of it
%Nikita
Cs scanf takes addresses as arguments, not arguments themselves. Otherwise segfault will occur
Levi
#include<stdio.h> int main() { int n; printf("enter a number \n"); scanf("%d",&n); return 0; }
Levi
tried ,but still nothing
Levi
i think i didnot setup correct environment for sublime
Levi
'cuz nothing's wrong in my code
Levi
its very basic though
Levi
Maybe
again thanks
%Nikita
it got the number but didn't do anything with it
Yep! The problem is it doesn’t take input
artemetra 🇺🇦
Yep! The problem is it doesn’t take input
the compiler might have optimised it away
%Nikita
Peco do u use any optimizations?
Levi
no
artemetra 🇺🇦
try printing the number afterwards #include<stdio.h> int main() { int n; printf("enter a number \n"); scanf("%d",&n); printf("%d",n); return 0; } will this still fail?
%Nikita
-O0 will turn off all optimizations
artemetra 🇺🇦
But you print address of n
oh sorry, i just mostly use C++
artemetra 🇺🇦
yes not working
does the program just terminate after the first print or does it print both?
Levi
after the first printf
Levi
first print works fine
%Nikita
Try it in gdb
%Nikita
I literally have no idea why isn’t it works
artemetra 🇺🇦
try #include<stdio.h> int main() { int n; printf("enter a number \n"); scanf("%d",&n); printf("second print\n"); printf("%d\n",n); return 0; }
Levi
maybe that will be easy
artemetra 🇺🇦
does it work fine if you compile it yourself in a separate terminal window (not sublime text)?
Levi
yes
Levi
just not in sublime
artemetra 🇺🇦
Artur
#include<stdio.h> int main() { int n; printf("enter a number \n"); scanf("%d",n); return 0; }
C++ ? Use the following #include <iostream> int main() { int n{}; std::cout << “enter a number” << std::endl; std::cin >> n; std::cout << n << std::endl; std::con.get(); return 0; } Or for more complex cases see boost spirit library
Artur
Using spirit you can do phrase matching and other crazy stuff
پویا رحیم
https://youtu.be/ykGOLShmcbQ
Hello, What is the best way to calculate inversions count of a vector of int with stl in c++? I do not want to write sort manually.
I can accept algorithm cost some memory, but I hope the time complexity is O(n log n), just like sorting it with count when swap.
ooops, sorry, I only need to now the partiy of the inversion, not the value of inversion.
Anonymous
At the peak of COVID-19, most worker started working from home. Salaries of workers were reduced by 30%. Assuming income tax was also reduced by 50% from the previous rate of 15% and workers were paid on the number of hour worked in a month and each worker is supposed to work a total of 170 hours in a month. All overtime has been cancelled. If a worker does not meet the 170 hours’ threshold for a 4 month, 5% is deducted from the salary. Write a java++ program for the scenario narrated above. Your program should: a) request for an employee’s name, the number of hours worked in a month [2 marks] AP b) define a function called payRole, your function should compute a worker’s salary and income tax and any deductions if any c) your program should display the results in “b” above. d) explain the logic behind the code especially the function
Anonymous
Please I need help
𝓓𝓪𝓻𝓴 𝓟𝓱𝓮𝓸𝓷𝓲𝔁
#include<stdio.h> main() { int i=2, j=3, k, l; float a, b; k=i/j*j; l=j/i*i; a=i/j*j; b=j/i*i; printf("%d\n%d\n%f\n%f", k, l, a, b); }
Anonymous
0 2 0.000000 2.000000
Anonymous
Anonymous
Hey somebody can plzz suggesti me more groups of c languages?
shuzuya
Hello I have a question relating to Linux and windows
shuzuya
Ask
Windows crushed and I cannot get to repair with recovery but I can access the files when I boot with Linux...so now am asking if there is a way to extract the softwares that were in windows partition as I can with the other files
Shubh Joshi
Hello, I have a doubt Actually for c++ , I am unable to setup VScode in Linux. I have downloaded VScode but for coding....I am unable to understand that how I can setup minGW in Linux
Shubh Joshi
So....please help me Thanks in advance