Pavel
it is gcc 4.8.1
Looking at this table, filesystem is supported only from GCC 8
https://en.cppreference.com/w/cpp/compiler_support/17#C.2B.2B17_library_features
Pavel
Or wait that's the library version.
Or actually seems to be that it's in sync with the GCC version itself, so should be GCC 8 or later
Saleh
Saleh
my version is so old
i have taken it from college lab lol
Sylvester Lim
Hi all, I am making a game where each player will pick a card and then see who wins, then this repeats for 5 rounds ... and they can choose whether to continue playing after the 5 rounds or not. I want to output the game logs into an output file where I used this method below :
int main{
do{
recordGameLogs(); // i call my function to record game logs here
}while(round <=5) //make the game run for 5 rounds
return 0;
}
void recordGameLogs()
{
ofstream outfile;
outfile.open("testwritezzz.txt", ios::app); // i used append mode to make sure that data is not overwritten after every round(as the game is played for at least 5 rounds)
if(outfile)
{
outfile << "Game Log --> Round " << roundNum <<endl;
outfile << "________________________________" << endl;
outfile << "(all player details etc etc)"
}
The code I sent is not complete, I just wanted to show a rough skeleton of the program. Anyways I used ::app , which is append mode to make the data be succesffuly written for all 5 rounds, if I just left it without append mode or trunc mode, the output file only records Round 5 details(as round 1 to 4 details are being overwritten). However, if i were to exit the program and decide to run it again , the previous game logs are still there. Is there any way for it to clear previous output content when the program is terminated, so everytime I run it only records the newest 5 rounds played .
Anyone knows how to overcome this issue?
Rickie
)
Create a class named Lease with attributes that hold an apartment tenant's name, apartment number, monthly rent amount, and term of the lease in months. Include a constructor that initializes the name to "XXX", the apartment number to 0, the rent to 15000, and the term to 12. Also include an accessor and a mutator method for each attribute. Include an instance method named addPetFee() that adds 1000 to the monthly rent value and calls a class method named explainPetPolicy() that displays a message explaining why the pet fee - such as "A pet owner pays an extra 1000 above the rent". (16 marks)
Pavel
Rickie
It's a question I want help with please.. Anyone
Rickie
net
what about c++ programming in macbook pro m1/m2?
Anonymous
#include <cstdio>
void add_one_to(int& x) {
x++;
}
int main() {
int i = 12;
printf("first: %d\n", i);
add_one_to(i);
printf("second: %d", i);
}
Anonymous
can you change this code using pointers
Anonymous
I'm having a hard time understanding pointers
\Device\NUL
I have a question regarding reference data type ie. int& . Does it work like global data so it doesn't require addditional allocation ?
Anonymous
net
can you change this code using pointers
#include <cstdio>
void add_one_to(int* x) {
*x++;
}
int main() {
int i = 12;
printf("first: %d\n", i);
add_one_to(&i);
printf("second: %d", i);
}
Anonymous
net
reference is an alias pointer
Pavel
I haven't worked with Mac a lot, but I remember the debugger in xCode was fine to work with. Maybe not perfect for something very specific or advanced, but I don't think it would matter for average tasks.
net
Anonymous
net
Anonymous
The pointer is supposed to change the value from 12 to 13
\Device\NUL
Anonymous
Anonymous
thank you
Anonymous
It worked
remember to check the type of the variable when you write code
Anonymous
Dimka
hello, what is the best way to handle and process errors in pure C(maybe something like try-catch in C++)
Aquatica
You don’t install programming languages
Andrey
hi, how i can stop system function execution? i try pid, but can't get pid from system
Deleted Account
What sources are you guys following to learn c language
Anonymous
hello everyone, advise me where you can just study the basics of c++
_
Hussein
Andrey
Andrey
I run system in one function and want to stop its execution in another function
Andrey
Getting PID with pipelines work terrible
Sketchyyy
#include <stdio.h>
//#include <cstring>
char char_multiply(const char c[], int i)
{
int n;
char s[] = c;
for(n = 1, s; n <= i; i++)
{
s += c;
}
return s;
}
int main()
{
const char c[] = "Hi";
printf("%s", c);
}
Can somebody tell what's wrong? (Newbie here)
\Device\NUL
\Device\NUL
Array parameter aren't exist btw, It will converted into pointer
\Device\NUL
Ahh I forgot to mention onething, The array will become dead object once it's out of scope. In this case s is dead, because the char_multiply func is end
Alireza
does anyone know about resource file in visual studio 2022 c++,How can I work with it? I read an article about it at microsoft documents but honestly ,I didn't understand it well
Hussein
macOS, but I want multi platform solution
I don’t think there is a cross-platform solution (at least not that I know of)
maybe there are few ways to do it on both Linux and BSDs (including mac) but windows is wildly different than the others
A..
Mark has decided to invest some money in the stock market, he bought one stock, the stock’s price was X dollars and he waited so he can sell this stock at a higher price than the price he bought it in.
One day the price of this stock became Y dollars and Mark decided to sell it in this day. Can you tell him how much profit he made from this investment?.
Input
The first line contains an integer T, the number of test cases.
Each test case consists of one line that contains two integers X and Y (1 ≤ X < Y ≤ 100), the price the
stock was bought in and the price the stock was sold in.
Output
For each test case print in a single line one integer, the profit earned from this stock
Hussein
I run system in one function and want to stop its execution in another function
you can create a fork process
with fork() this will create a child process then you need to call your function by the child
the fork() function returns a process id (if I’m not mistaken)
the child process will work in parallel with your parent process (your main program)
then in your main function you can use kill() with the process id to kill the child you’ve created
A..
Roxifλsz 🇱🇹
Not an ad bruv
A..
I slove it but still give me error
Hussein
Pavel
What is going on!
Next time start your message not directly from your task description, give some context :)
I also almost reported it :)
/
hi i have a question
/
char * ret = new char [ size + 1 ];
/
when i create this should i always delete it
mack
yes
mack
because you use new
/
mack
it's no big deal
/
/
then i need to create like a normal char array
/
and return it
mack
i think you can you use create way provide from c/c++ itself
/
Vladimir
/
/
i use std strings but when i import the string library the file become 1 mb
Vladimir
because its bytes
std::string is an std::basic_string<char>, so it is an array of chars.
/
/
mack
Is file size your main concern?