Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
The code using printf and cout:
int a=0;
a=printf("Hello World");
cout<<" "<<a;
Output :
11Hello World
The code using printf:
int a=0;
a=printf("Hello World");
printf("%d ",a);
Output :
Hello World11
You must have disabled synchronization between std::cout and C API?
If it is enabled I can't reproduced it
If I disable this synchronization I reproduce observed output.
For more information read about std::ios::sync_with_stdio
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I made a simple c++ program:
#include <iostream>
int main(){
for (int i = 0; i >=; i++){
std::cout << i << "\n";
}
return 0;
}
It compiles but the output .exe doesn't run.
Edit: I used GNAT Studio 2021 compiler.
The termination condition is incorrect : i >=.
You can choose a number of turn of the loop, for exemple 10 with : i<=10.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
the code i wrote
What am i doing wrong in here it gives me an error and its very very basic.
enter code here
# include <iostream>
using namespace std;
int main()
{
string firstone = "giraffe academy";
cout << firstone.substr(8, 3);
return 0;
}
You need to
# include <string>
that defines << for std::string
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I am using https://godbolt.org/ to compile a simple C++ script but even the simplest
int main()
{
std::cout << "Hello World!" << std::endl;
}
When I click Add new... --> Compiler --> Output I get: Compiler returned: 0
As #Ayxan Haqverdili told me the missing steps are Output... > Run the compiled output
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I have to get numbers from file and some of them are negative. So, how can I do that? (C++)
Now I'm trying just this (without something special):
U1.txt file:
4 5 -1 6 -2
My code:
ifstream fd(FD);
int n1,n2,n3,n4,n5;
fd>>n1>>n2>>n3>>n4>>n5;
Your code is basically correct, except for that typo with n4 missing.
This:
ifstream fd("U1.txt");
int n1,n2,n3,n4,n5;
fd>>n1>>n2>>n3>>n4>>n5;
Will do what you expect, modulo error conditions.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
i want to print a Sequential that decreased by 5
using a for loop
but i don't know why it doesn't print the output :(
#include<bits/stdc++.h>
using namespace std;
int main(){
for(int j=60;j<=0;j-=5){
cout<<j<<endl;
}
}
whats the wrong?!
Change it to
for(int j=60;j>=0;j-=5){
^^