Next Pallindrome

Can, anybody help me this code of next pallindrome given below.
Problem link:http://www.codechef.com/problems/PALIN

It works for the test cases but is not accepted by the judge.

#include
using namespace std;

int reverse(int k)
{
int ans=0;
while(k>0)
{
ans=ans*10+k%10;
k=k/10;
}
return ans;
}

int func(int k)
{
int rev;
while(1)
{
k++;
rev=reverse(k);
if(rev==k) break;

}
return rev;

}

int main()
{
int t;
cin>>t;
while(t–){
int k;
cin>>k;
cout<<func(k)<<endl;}
return 0;
}

@code_chef_abhi, read the question properly…it says the number can have as many as 1000000 digits which u cannot store in an int data type…u will need a suitable data structure for this…

//