DIGIT-ARC read-only archive · snapshot: July 23, 2026

Solution needed for 2 problems

6 posts · originally from https://geek.digit.in/community/threads/solution-needed-for-2-problems.37896/

n2casey
n2casey Original post #1
Oct 4, 2006 at 3:01 AM
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.
S
Oct 4, 2006 at 7:07 AM
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.
n2casey
n2casey #3
Oct 4, 2006 at 11:04 PM
So I m asking again for solution. I have made some changes to prog (removed silly mistakes). Anyone will try???
S
Oct 5, 2006 at 7:09 AM
Remove ';' from return (c); statement.

Arun
swatkat
swatkat #5
Oct 6, 2006 at 12:57 AM
Hi,
Make the function return a pointer to string or pass the string as argument.
n2casey
n2casey #6
Oct 6, 2006 at 1:24 AM
@ 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.