Friday 5 February 2016

Signatures of a Function (C++)

Signatures of a Function (C++)

Description:    The following C++ code


C++ Code

#include <iostream>
#include <fstream>
using namespace std;

int main()
{
   char input[100],signature[100];
   int j=0, w, no_of_arguements=0, no_of_equals=0, no_of_signatures=0, check=0, equals=0;  
   ifstream fin("input.txt");
   fin.getline(input,49);
   int lenght=strlen(input);
   for (int i=5;i<lenght;i++)
   {
      if (input[i]=='i'&& input[i+1]=='n')
          no_of_arguements++;
      if (input[i]=='=')
          no_of_equals++;
   }
   if (no_of_arguements!=0)
      no_of_signatures=1+no_of_equals;
   
   system("color 0e");
   cout<<"The number of possible signatures are "<<no_of_signatures<<endl<<endl;
   
   if (no_of_signatures==1) //if number of signatures is 1
      cout<<input<<endl<<endl;
   else
   {
      for (int h=1;h<=no_of_signatures;h++)
       {
           equals=0;
           for (j=0;j<lenght;j++)
           {
               if (input[j+5]=='=')
               {
                  if (check==equals)
                  {
                     if (signature[j-1]==',')
                     {
                        signature[j-1]=')';
                        signature[j]='\0';
                     }
                     else
                     {
                        signature[j]=')';
                        signature[j+1]='\0';
                     }
                     check++;
                     break;
                  }
                  else
                     signature[j]=input[j];
                  equals++;
               }
              else
                  signature[j]=input[j];
           }
           if (j==lenght)
               signature[j]='\0';
           int lenght_signature=strlen(signature);
           for (int s=0;s<lenght_signature;s++)
           {
               if ( (signature[s]>='0' && signature[s]<='9') || signature[s]=='=')
               {
                  for (w=s;signature[w]!='\0';w++)
                      signature[w]=signature[w+1];
                  
                  s--;
               }
           }
           cout<<" "<<signature<<endl<<endl;
        }
   }
  
   return 0;
}


1 comment

  1. Thought-provoking ideas ! I Appreciate the details ! Does anyone know if my company might be able to get access to a template TSP-75 form to use ?

    ReplyDelete

Recent Posts