Q BgQuestion:

      
Rookie
Karma Points: 23
Respect (93%):
posted by  Love Lake on 11/7/2009 9:17:28 AM  |  status: Closed  |  Earned Karma: 23

Win32 Program with the name “Add” that takes a string as input at command line.

Course Textbook Chapter Problem Needs by
Software Design N/A N/A N/A 11/7/2009 at 11:00:00 PM
Question Details:

AAnswers:

Answer Question Ask for clarification
Oracle
Karma Points: 31,807
posted by rapunzel on 11/7/2009 10:36:57 AM  |  status: Live
Asker's Rating: Lifesaver   
Response Details:
please rate - thanks

#include <iostream>
#include <windows.h>
using namespace std;

int main(int argc, char * argv[])
{int len,loc,num1=0,num2=0,sum=0,i;
string input=argv[1];
len=input.length();
loc=input.find(',',0);
cout<<input<<" "<<len<<" "<<loc<<endl;
for(i=0;i<loc;i++)
    num1=input[i]-48+num1*10;             //-48 to change from ASCII representation to int
for(i=loc+1;i<len;i++)
    num2=input[i]-48+num2*10;            //same as above
sum=num1+num2;
cout<<num1<<" "<<num2<<" "<<sum;       
 char buf [20];
sprintf(buf,"Sum = %d",sum);
MessageBox(0,buf,"OK", MB_OK );
 
return 0;
  }

Note to all members 1. Please 1 question per post 2. Show respect to your fellow members by rating all answers. 3. When rating remember that the first answer is not necessarily the best answer. 4. When answering questions, explain what you are doing, so that the asker will learn, don't just give a meaningless number. 5. Your answers should be your work. Don't copy from another member, this is Karma abuse and possible disciplinary actions against you. and GOOD LUCK to you all!!
Answer Question Ask for clarificarion

Join Cramster's Community

Cramster.com brings together students, educators and subject enthusiasts in an online study community. With around-the-clock expert help and a community of over 100,000 knowledgeable members, you can find the help you need, whenever you need it. Join for free today » How Cramster is different from tutoring »