16,012,759 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Rahul Thengadi (Top 20 by date)
Rahul Thengadi
18-Jun-16 13:31pm
View
after applying above solution it shows: Segmentation fault (core dumped)
Rahul Thengadi
9-Jun-16 1:46am
View
i will improve my the question, i think you didn't get the whole situation.
Rahul Thengadi
9-Jun-16 0:18am
View
But in the problem it is clearly specified that the the integers are delimited by space and should be accepted through console.
I tried getline(cin,temp) and then check the temp.empty().But as i used getline method i can't check whether user has given correct input
Rahul Thengadi
8-Jun-16 23:10pm
View
It is console input and input should separated by space.
Im using fedora
Rahul Thengadi
8-Jun-16 5:57am
View
Ya i will try one more time as soon as new version of g++ compiler is installed on my pc.
The old compiler wasn't supporting 'stoi' so i tested that program on codechef online ide.
Rahul Thengadi
7-Jun-16 17:12pm
View
I tried your solution, it ended up with input(3,1)=>output(4) and for input('a','b')=>output(195)
Rahul Thengadi
7-Jun-16 17:07pm
View
I come up to conclusion that it can't be solved logically using normal functions.Because the point you initialise num1 and num2 variables(i.e. the input which is hardcoded). For "intger type" it get "decimal value" and for "character"(i.e. int num1 = 'a') it also a decimal value('a' gets value 97 in ascii which is also decimal) no matter which logic or condition you apply, you can't end up the expected solution.
The only way it can be solved using polymorphism and RTTI (i.e. Run Time Type Information).I am working on it.
Rahul Thengadi
7-Jun-16 16:04pm
View
The solution you have given was solution to my next problem.You have explained it very well.
Thank you so much...
Rahul Thengadi
7-Jun-16 15:49pm
View
Probably the compiler version doesn't support stoi()
Rahul Thengadi
7-Jun-16 15:47pm
View
Ya it is in my program
Rahul Thengadi
7-Jun-16 15:35pm
View
Thanks , the validNum() is much useful, i was nearly close to the answer
Rahul Thengadi
7-Jun-16 15:23pm
View
Finally getting 'stoi' was not declared in this scope
Rahul Thengadi
7-Jun-16 11:41am
View
Hardcoded means sample input values should written in program i.e. program should not prompt for input values to user
Rahul Thengadi
7-Jun-16 11:18am
View
ya i will ensure from that sorry
Rahul Thengadi
7-Jun-16 11:11am
View
#include<iostream>
using std::cout;
using std::cin;
using std::endl;
int add(int num1,int num2)
{
if(isdigit(num1) != 0 && isdigit(num2) != 0)
{
cout << num1+num2;
}
else
cout << "Error" << endl;
}
int main()
{
int num1 = 3;
int num2 = 1;
add(num1,num2);
num1 = 'a'; // here num1 value is 97 i.e. ASCII value of character a
num2 = 'b'; // here num1 value is 97 i.e. ASCII value of character a
add(num1,num2);
return 0;
}
Output: Error
Error
Rahul Thengadi
7-Jun-16 10:57am
View
Ya i think but the inputs were hard coded
Rahul Thengadi
7-Jun-16 10:31am
View
As the int num1 = 'a';
Here num1 = 97 // ASCII value of 'a'
isdigit can't handle it
Rahul Thengadi
7-Jun-16 10:05am
View
I just got the solution that i was using cout << "\n"; to print next column in matrix instead i must use ofstream obect i.e. outFile << "\n"; as i want output in textfile
Rahul Thengadi
7-Jun-16 10:03am
View
Yes but in vmware workstation cs50 appliance
Rahul Thengadi
7-Jun-16 10:01am
View
I just got the solution that i was using cout << "\n"; to print next column in matrix instead i must use ofstream obect i.e. outFile << "\n"; as i want output in textfile
Show More