Anonymous
why don't copy the code in here or paste it on ideone or pastebin or somethin?
Anonymous
okl
aura_
Can anybody suggest best book to buy for learning programming for beginners . I am new in this group plz help
Anonymous
ok
Anonymous
Anonymous
#include<iostream>
#include<fstream>
#include<string>
#include<math.h>
using namespace std;
int main()
{
ifstream obj("student.csv");
if(!obj.is_open()) std::cout<<"File Open "<<endl;
int avg,total,eng,mat,sci;
string name;
string english;
eng=stoi(english);
string math;
mat=stoi(math);
string science;
sci=stoi(science);
while(obj.good())
{
getline(obj,name,',');
getline(obj,english,',');
getline(obj,math,',');
getline(obj,science);
total=(eng+mat+sci);
cout<<name<<" Your total Marks are :"<<total;
}
}
Anonymous
aura_
aura_
Anonymous
Thnx
don't mention it
aura_
Ok
Anonymous
it used to have pdf version.. dunno where the file gone...
Anonymous
brb
olli
#include<iostream>
#include<fstream>
#include<string>
#include<math.h>
using namespace std;
int main()
{
ifstream obj("student.csv");
if(!obj.is_open()) std::cout<<"File Open "<<endl;
int avg,total,eng,mat,sci;
string name;
string english;
eng=stoi(english);
string math;
mat=stoi(math);
string science;
sci=stoi(science);
while(obj.good())
{
getline(obj,name,',');
getline(obj,english,',');
getline(obj,math,',');
getline(obj,science);
total=(eng+mat+sci);
cout<<name<<" Your total Marks are :"<<total;
}
}
which compiler are you using? This should compile with a c++11 compiler.
std::stoi was introduced in C++11
Anonymous
anyone with networking PDF?
Anonymous
olli
codeblocks
That's your IDE/Editor. Not your compiler..
Mat
#include<iostream>
#include<fstream>
#include<string>
#include<math.h>
using namespace std;
int main()
{
ifstream obj("student.csv");
if(!obj.is_open()) std::cout<<"File Open "<<endl;
int avg,total,eng,mat,sci;
string name;
string english;
eng=stoi(english);
string math;
mat=stoi(math);
string science;
sci=stoi(science);
while(obj.good())
{
getline(obj,name,',');
getline(obj,english,',');
getline(obj,math,',');
getline(obj,science);
total=(eng+mat+sci);
cout<<name<<" Your total Marks are :"<<total;
}
}
It doesn't give me any errors🤔
Anonymous
Anonymous
how can I know about my compiler?
aura_
Thnx
Anonymous
its gnu gcc
Deni
codeblocks
I remember that with codeblocks you can enable c++11
Anonymous
ok I am doing it now
Anonymous
@Akkuq oh yeah, it wasn't cover the latest C++ version but it'll give you very good of most fundamentals of C++ (and some other things were added and modified in the latest C++)
aura_
Yup I am waiting 😊
Anonymous
terminate called after throwing an instance of 'std::invalid_argument'
what(): stoi
Anonymous
I got this error
Anonymous
aura_
It will
Anonymous
you can find your own resources for C++ and C++11
Deni
#include <iostream>
#include <string>
int main(){
std::string b="1";
int a=std::stoi(b);
std::cout<<a;
}
Deni
Result:
1
Deni
This code on rextester works
Anonymous
I am tryng to get data from csv file and convert it to integer
olli
the string you're trying to convert probably contains not digits only
Anonymous
math.h header is not a C++ one , use #include <cmath>
Anonymous
Ok
Anonymous
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
int main()
{
string name,eng,math,science;
ofstream marks;
marks.open("student.csv");
marks<<"Name"<<","<<"English"<<","<<"math"<<","<<"science"<<endl;
for(int i=0; i<5; i++)
{
cout<<"Enter your name :";
getline(cin, name);
cout<<"Enter Marks obtained in Subjects given :"<<endl;
cout<<"English: "<<endl;
getline(cin, eng);
cout<<"Math: "<<endl;
getline(cin, math);
cout<<"Science: "<<endl;
getline(cin, science);
marks<<name<<","<<eng<<","<<math<<","<<science<<endl;
}
}
Anonymous
I created my database from this code
Anonymous
#include <iostream>
using namespace std;
void seclection(int arr[],int siz);
int main() {
int arr[]={77,5,43,23,56,78,98,76,54,32,34,56,7,89,87,65,4};
int size= sizeof(arr)/sizeof(arr[0]);
seclection(arr,size);
for(int i=0;i<20;i++){
cout << arr[i] << " ";
}
return 0;
}
void seclection(int arr[],int siz){
int i,j,k,t,c;
for(i=0;i<siz;i++){
k=arr[i];
for(j=i+1;j<siz;j++){
if(arr[j] < k){
k=arr[j];
c=j;
}
}
t= arr[j];
arr[j]=arr[i];
arr[i]=arr[j];
}
}
Anonymous
i am trying to make seclection sort
Ubeid
Hey guys.. thanks so much for creating this group!
I've studied basic of C language at uni last year, and i wanna learn more! I use my phone, can u recommand any app for Android?
Dima
Why mobile/android tho?
Anonymous
problem solved
Anonymous
applications built by c++ wont stay on screen
Anonymous
disappers quickly
Ubeid
Sure
Deni
Sure
You can program in C++ on Android with ndk, but i council to use only Java for Android and use C++ only for the optimization of the app
Anonymous
#include<iostream>
#include<fstream>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
ifstream obj("student.csv");
if(!obj.is_open()) std::cout<<"File Open "<<endl;
int avg,total,eng,mat,sci;
string name;
string english;
string math;
string science;
while(obj.good())
{
getline(obj,name,',');
getline(obj,english,',');
getline(obj,math,',');
getline(obj,science);
eng=stoi(english);
mat=stoi(math);
sci=stoi(science);
total=(eng+mat+sci);
avg=total/3;
cout<<name<<" Your total Marks are :"<<total<<" Average marks are :"<<avg<<endl;
ofstream average;
average.open("Final Marksheet.csv");
average<<"Name"<<","<<"English"<<","<<"Mathematics"<<","<<"Science"<<endl;
for(int i=0; i<5; i++)
{
average<<name<<","<<eng<<","<<mat<<","<<sci<<","<<avg<<endl;
}
}
getchar();
return 0;
}
Anonymous
name is not getting in final csv file
Anonymous
pls help
Ubeid
Anonymous
can I use auto v{1,2,3}; in c++11 ?
Ubeid
Anonymous
#include<iostream>
#include<fstream>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
ifstream obj("student.csv");
if(!obj.is_open()) std::cout<<"File Open "<<endl;
int avg,total,eng,mat,sci;
string name;
string english;
string math;
string science;
while(obj.good())
{
getline(obj,name,',');
getline(obj,english,',');
getline(obj,math,',');
getline(obj,science);
eng=stoi(english);
mat=stoi(math);
sci=stoi(science);
total=(eng+mat+sci);
avg=total/3;
cout<<name<<" Your total Marks are :"<<total<<" Average marks are :"<<avg<<endl;
ofstream average;
average.open("Final Marksheet.csv");
average<<"Name"<<","<<"English"<<","<<"Mathematics"<<","<<"Science"<<endl;
for(int i=0; i<5; i++)
{
average<<name<<","<<eng<<","<<mat<<","<<sci<<","<<avg<<endl;
}
}
getchar();
return 0;
}
help with this guys stuck at small bug
Anonymous
Hello there! I have a question regarding using Regular Expressions in C++.
So, + in regex means repentance of the preceding character one or more times and [abc] means any of the character inside [] that is any of the char from a, b and c will match. Following from the above two [abc]+ should match any string containing only arbitrary number of a, b and c that is, aabbbbc, acccc, accccbbb, bbc, etc all will match. Also ' . ' is a wildcard character that matches any character and whitespace except newline.Am I right till here? I hope so, if not please correct me.
Now to match a string "Hello\n I am a C++ programmer" I wrote the regex [.\n]+ and it did not work. But when I changed it to .+\n.+ to my surprise it worked then. Can anyone tell me what am I doing wrong?
olli
Hello there! I have a question regarding using Regular Expressions in C++.
So, + in regex means repentance of the preceding character one or more times and [abc] means any of the character inside [] that is any of the char from a, b and c will match. Following from the above two [abc]+ should match any string containing only arbitrary number of a, b and c that is, aabbbbc, acccc, accccbbb, bbc, etc all will match. Also ' . ' is a wildcard character that matches any character and whitespace except newline.Am I right till here? I hope so, if not please correct me.
Now to match a string "Hello\n I am a C++ programmer" I wrote the regex [.\n]+ and it did not work. But when I changed it to .+\n.+ to my surprise it worked then. Can anyone tell me what am I doing wrong?
Inside a character class everything except ^, -, ] or \ is always a literal. [.]{3} therefore only matches ...
Anonymous
Ս
HI everyone!
Ս
who can help we with understanding a code?
Ս
https://paste.fedoraproject.org/paste/KxYdPHI~1QamFhIQIDtnDA
Saurabh
Which is the best python book for reading?
Max
P
#include<iostream>
#include<fstream>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
ifstream obj("student.csv");
if(!obj.is_open()) std::cout<<"File Open "<<endl;
int avg,total,eng,mat,sci;
string name;
string english;
string math;
string science;
while(obj.good())
{
getline(obj,name,',');
getline(obj,english,',');
getline(obj,math,',');
getline(obj,science);
eng=stoi(english);
mat=stoi(math);
sci=stoi(science);
total=(eng+mat+sci);
avg=total/3;
cout<<name<<" Your total Marks are :"<<total<<" Average marks are :"<<avg<<endl;
ofstream average;
average.open("Final Marksheet.csv");
average<<"Name"<<","<<"English"<<","<<"Mathematics"<<","<<"Science"<<endl;
for(int i=0; i<5; i++)
{
average<<name<<","<<eng<<","<<mat<<","<<sci<<","<<avg<<endl;
}
}
getchar();
return 0;
}
Can you explain what use of getline
klimi
?
Surya
Okk
Anonymous