Quick C Strange Problems
Shekar_Narayanan.SV at Xerox.COM
Shekar_Narayanan.SV at Xerox.COM
Tue Mar 8 08:11:27 AEST 1988
Hello there,
I am using QuickC for some development at my leisure at home. I am having the
strange problems as described below:
1) With character pointers. The code reads like this.
char *getstring(col, row, len)
int col, row, len;
{
char *temp, *s;
char ch;
int count;
gotoxy(col, row);
clearxy(col, row); /* clear upto end of row */
gotoxy(col, row):
temp = s;
count = 0;
for (;;)
{
if (count > len) return temp;
ch = getkey(); /* get a key from user */
if (ch == ESC) return NULL;
switch (ch)
{
case CR:
*s = ch;
return temp;
break;
case BS:
if (count > 0)
{
*(s --) = '\0';
col --;
count --;
}
break;
default:
*s = ch;
s++;
col++;
count ++;
break;
}
gotoxy(col, row);
putchar(ch);
}
}
In this code what I expect to see is that the return in "temp" should contain
the char array that "s" accumulated in the process. Instead, while debugging I
found that "temp" was pointing only to the last character in the array. Also the
char pointers temp and s are pointing to garbage string of characters from
nowhere at the first line of the program. I am not sure what is wrong here. Do I
need to forcefully do strcpy(temp, ""); to initialise the char pointers
everytime.
2) If I use the C library functions int86 to manipulate cursor and other goodies
via dos interrupt and somewhere else in the program I use direct video ram
access to write to screen then things go crazy. Is there any limitation that is
not documentated in QuickC.
3) Finally, I somehow got my program running and compiling in memory in QC
environment and when I create and exe image from QC and try to run it from dos
command line the screen just freezes and I have to reboot. I had only the stack
checking and language extensions options turned on in compiling the program. I
am not sure what is wrong.
4) I am also interested in some more information on QC library calls for Memory
resident programs using the calls _setvec _getvec etc . There are absolutely
no examples in the run time library documentation.
Would appreciate any input.
Thanks in advance,
Shekar
More information about the Comp.lang.c
mailing list