The problem is that my program crasches when at line 13. Pot10 i an int and lgth is an int so whats the problem? I can't figure it out:(

typedef struct ArrInt{
int intM[100], lgth;
} megaint;

void scanMeg(megaint *x){
     int Pot10 = 0, ret,IntArr[100];
     char c;
     while( (c = getchar()) != '\n'){
            IntArr[Pot10] = atoi(&c);
            Pot10++;
     }

     x->lgth = Pot10;

     for(ret=0; Pot10 >= 0; Pot10--, ret++)
         x->intM[ret] = IntArr[Pot10];
}

atoi() expects a pointer to a char array, containing a \0 char at some point?
A single char doesn't work. IntArr[Pot10] = c - '0';

Strangely that doesn't crasch the program but x->lgth = Pot10; does crasch the program...

Well then, you need to show how you call the function.

If you have scanMeg( &megaint ); I can't see a problem.

But if you have

ArrInt *myBigInt;
scanMeg( myBigInt );

then you're on a road to nowhere with unallocated memory and uninitialised pointers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.