Nils
Um will it be std::chrono_literals::this_thread::sleep_for(1s) If I use it without the namespace statement ?
no, it would be std::this_thread::sleep_for(std::chrono_literals::s(1)); without it
Anonymous
Thankyou so much, it worked
Anonymous
no, it would be std::this_thread::sleep_for(std::chrono_literals::s(1)); without it
Don't do it, User-defined literals operators are meant to be in a global namespace.
Anonymous
Hi. Plz how can i get an integer from a file an assign it to a variable?
Anonymous
Plz
Anonymous
In c
Nils
In c
fscanf
Anonymous
Plz just write the full command
Anonymous
Plz just write the full command
int fscanf(FILE *restrict stream, const char *restrict format, ...);
Nils
Plz just write the full command
FILE *f = fopen("file.txt", "r"); int num; fscanf(f, "%d", &num); fclose(f);
Anonymous
So can i assign it to a variable?
Anonymous
Likk a=fscanf()
Anonymous
?
Anonymous
Likk a=fscanf()
No cos fscanf would probably return the number of chars read instead of the chat itself
Anonymous
Just like scanf
Anonymous
Just like scanf
Plz give me the command.
Vlad
So can i assign it to a variable?
Bruh do you know what pointers are?
Nils
So can i assign it to a variable?
That is what my code does. It assigns the number read to num
Vlad
Bruh do you know what pointers are?
You pass an address of your variable to the scanf function
Anonymous
🙏
Nils
Thanks bro. Let me give a try
And... Just asking, do you actually understand how that code works?
Anonymous
And... Just asking, do you actually understand how that code works?
Yes. I want to get an iteger from a file and assign the integer to a variable.
Anonymous
At a particular position in the file. Plz help me
Anonymous
🙏
Anonymous
Sorry, someone has an ebook stuck, queue ? 🙏
Anonymous
Plz write the command
Anonymous
Plz write the command
Ammar
Plz write the command
See: man 3 fseek
Anonymous
Plz write the command
Before you want to write code, you must learn: http://www.it.uc3m.es/pbasanta/asng/course_notes/ctut.pdf We are not suppose to solve your homework.
Eugene
Hi guys I'm a noob here, doing C, I wanted to ask after learning the basics, where do I go from there?
сумбула
Hi guys I'm a noob here, doing C, I wanted to ask after learning the basics, where do I go from there?
Hi, if you have learned basics then you can practice your knowledge by making little projects, or you can upgrade your knowledge by reading books
Soni
Is this correct code?
Soni
#include<stdio.h> #include<conio.h> char main() { printf("Hello"); getch(); return 0; }
Vala
#include<stdio.h> #include<conio.h> char main() { printf("Hello"); getch(); return 0; }
Soni
Can you explain?
Anonymous
Is this correct code?
1- Do not include the conio.h header file, it's MS-DOS header file and non-portable. 2- The main() function signature is int main(), int main(int argc, char* argv[]) and int main(int argc, char* argv[], char* envp[]). ---------------- #include <stdio.h> int main() { printf("Hello\n"); }
Soni
#include<stdio.h> #include<conio.h> char main() { printf("Hello"); getch(); return 0; }
But when I have run this code in system then I get output i.e hello... If this is incorrect it will have to genrate error msg why execution of program happened?
Anonymous
But when I have run this code in system then I get output i.e hello... If this is incorrect it will have to genrate error msg why execution of program happened?
The main() function should return int, type char could be converted to int and the compiler does that for you. https://en.cppreference.com/w/c/language/main_function
H
The main() function should return int, type char could be converted to int and the compiler does that for you. https://en.cppreference.com/w/c/language/main_function
why returning int? 🤔 really we need sizeof(int) states? or better question , do we have states more than 256? (edited: for returning to OS.)
H
👍👍👍 Thanks
Anonymous
@adreup Read: §6.9.3.1 [basic.start.main] N4868
H
@adreup Read: §6.9.3.1 [basic.start.main] N4868
Thanks, I readed something like this , but never know why int ... I will read this link too , thx again.
Lion
why returning int? 🤔 really we need sizeof(int) states? or better question , do we have states more than 256? (edited: for returning to OS.)
UNIX has been using status & 0xFF since the old days, but standardised C as int for portability.
Soni
The main() function should return int, type char could be converted to int and the compiler does that for you. https://en.cppreference.com/w/c/language/main_function
Can you explain how main function call by os and how memory allocated for declared variable of that programming
Lion
Otherwise the standard will be actually forcing other OS to be implemented as the same (few return status).
Anonymous
Soni
I am begginer in c language please explain in basic term
Lion
Yesss
Lion
I am begginer in c language please explain in basic term
A wrapper calls your main. It could be provided by your compilers, C runtime library and/or other libraries in operating system.
Anonymous
I am begginer in c language please explain in basic term
At the begging of learning Programming With The C Language, you don't need to know how the main() function begins called. But ... See this talk: https://www.youtube.com/watch?v=dOfucXtyEsU
Lion
Maybe you can image there are bunch of functions before main.
Anonymous
Ig means?
ig = i guess
Soni
😂😂
Soni
Ok
Lion
The whole process of executing a program in Linux is extremely complicated and also interesting
Lion
For example, executing a program is almost always actually executing another super powerful program (called loader) to load the program into memory rather than directly executing the program.
Lion
Interpreter, the name of this mechanism.
Soni
Ok thnq
Soni
main() { printf("Hello"); getch(); }
Soni
Is this program run in c with extension .c
Lion
main() { printf("Hello"); getch(); }
Too K&R. Use "int main" instead.
Soni
Any other error Have you noticed?
Anonymous
Is this program run in c with extension .c
Are you doing a test somewhere?
Soni
No