-
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");
}
-
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.
-
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!!!!
-
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