Thread: debugging code

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    21

    debugging code

    hi, first of all, i would like to congratulate u all guys for this beautifull board! looks pretty nice u know...
    Im a very loyal member of all boards, so, from now on, ull see me around lotz of times.
    My native language is Spanish, but i can handdle my english in a good way...i hope u can understand me.


    ok, now, im making a proyect, but i get an error in a line of my code, not when compiling, but when running... the idea of this code is to write a mesagge in an array, then, transfer it into a matrix, and once again, pass it to an other array, colum by colum, but in a very nice way... heres my code, please help me..


    OH, by the way, i havent learnded to use poiters, so please dont use any, thanx


    thanx in advanced...


    ----------------------------------------------------


    #include <stdio.h>
    #include <stdlib.h>
    #include <iostream.h>
    #include <conio.h>

    #define tamcla 20
    #define tammens 50
    #define matfi 50
    #define matcol 50

    int valmin(struct pass, int);
    int mat2mencri(char [matfi][matcol], char [], int, int);
    void men2mat(char [], char [matfi][matcol], int);
    void show(char [matfi][matcol]);


    struct pass {
    char car[tamcla];
    char ava[tamcla];
    };

    pass clave;

    main(){
    int recla, q, r, d;
    char mensaje[tammens], basen[matfi][matcol], mencri[tammens];
    int min[tamcla];
    printf("# of characters for the password:\n");
    cin>>recla;
    printf("type your password\n");
    cin>>clave.car;

    printf("type your mesagge\n");
    cin>>mensaje;

    for (q=0; q<recla; q++){
    men2mat(mensaje, basen, recla);
    d=valmin(clave, recla);
    r=mat2mencri(basen[matfi][matcol], mencri[], d, r)
    cout<<d;
    getch();
    }

    system("pause");
    }


    int mat2mencri(char basen[matfi][matcol], char mencri[], int d, int r){
    int h;

    for(h=0;h<matfi;h++){
    mencri[r]=basen[h][d];
    }
    return r;
    }



    void men2mat(char mensaje[], char basen[matfi][matcol], int recla){
    int c=0, h,col;

    for(h=0, c=0; c<tammens;h++){
    for(col=0; col<recla; col++, c++){
    basen[h][col]=mensaje[c];
    }
    }
    }



    int valmin( pass clave, int recla){
    int count;

    for (count=0; count<recla; count++){
    if ((clave.car[count]< clave.car[(count+1)]) && (clave.ava[count] !='n')){
    clave.ava[count]='n';
    }
    }
    return (count);
    }




    void show (char a[matfi][matcol]) {
    int x, j;
    for (x=0; x<tammens; x++){
    printf("\n");
    for (j=0; j<tammens; j++){
    printf("%3c",a[x][j]);
    }
    }
    printf("\n");
    }
    Last edited by DeViLs_SouL; 12-04-2001 at 09:53 PM.

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    30

    Hi DS.

    I could not even compile the code, I am using Dev c++.

    You do not have a return statement for yout main() function.
    Also your main() function should be 'int main()' (not necessary on all compilers though.

    I corrected these errors but I could still couldn't get it to compile...
    I will have another look later when I've got more time.
    Homer

    D'OH!

    mmmmmmmm... iterations

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    21
    yeah, i have noticed that, i have no idea why, but what i write in borland, cant be compiled in Dev. thats weird, cuz it gives me no problems when compiling....

    please help!!!!

  4. #4
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    i have noticed that my borland code wont compile in Dev, i think its because Dev uses some odd syntax rules.

    Run time errors can be caused by many factors, if it is an array make sure it is not overflowing ((ie if its an 8 bit array, make sure your not entering 12 bits - it will cause an RTE)

    To prevent these try validating the string length, i wll have a look at the code and see if i can compile it in Borland
    Monday - what a way to spend a seventh of your life

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. backward debugging in Visual Studio??
    By George2 in forum Tech Board
    Replies: 12
    Last Post: 11-05-2006, 02:17 AM
  2. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  3. Replies: 8
    Last Post: 04-28-2003, 07:29 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Debugging leads to buggy code and longer hours?
    By no-one in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 01-28-2002, 11:14 AM