Solution needed for 2 problems

Status
Not open for further replies.

n2casey

Super Hero - Super Powers
I have P-4 1.7 GHZ, 256 MB DDR RAM, 40 GB sys.
I m using WinXP Pro SP2, NAV 2005.

  • I have some CD which I write few months b4 but now I came 2 know that each s/w, present on those CDs is infected with Win32 Valla & Pinfi viruses. I tried to repair files with NAV but it modified/corrupted files & files can't b used now. So how can I remove viruses from s/w without modifying or harming them. Once s/w will b repaired, I will burn them on other CDs.
  • I m programing in C++. Take a look at the following prog.

Code:
char func()
{
   int i=0;
   char c='\0', p[25]={'\0'};
   while(c!=13)
   {
       c=getch();
       
       if(c==27)
       break;

       else if(c>32 && c<126)
       {
       p[m]=c;
       m++;
       }
    }
     if(c==27)
     return(c);
     else
     return(p);   // here it is not possible to return this string
}

void main()
{
   char q[25]={'\0'};
   q=func();     // here I want to assign value of p to q
}

So any one can tell me that how can I return the complete string.

Above porg is not complete & is a part of another prog, so don't say that prog is incomplete.
__________
Ooops!
OK I have made the necessary changes & I will not enter more that 34 characters so there will not b any overflow.
Now tell me the solution.
 
Last edited:

sakumar79

Technomancer
For the second query, remove the "if(c==27) return(c); else" portion of code. After the while loop is over, c must be 27 because that is the only condition when the loop will be over.

Arun

Note: m is not initialized here, perhaps it is initialized elsewhere. Also, you may want to include a check on m in the while loop condition to avoid overflow of array.
 
OP
n2casey

n2casey

Super Hero - Super Powers
So I m asking again for solution. I have made some changes to prog (removed silly mistakes). Anyone will try???
 
OP
n2casey

n2casey

Super Hero - Super Powers
@ swatkat

I have tried both options & both r working. Thx for ur help.
Actually, I was knowing that but I forgot coz I m programing in C++ after 1 yr. For last 1 yr I was prog in VB.
 
Status
Not open for further replies.
Top Bottom