473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

General Protection Exception

I am a mathematician trying to write a program in C to do some curve
fitting. When I get to the point where I attempt to enter data in my
arrays, I get a General Protection Exception error message. What is
this and how can I fix it. I am writing in Turbo C++. My source code is
below.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
/* Integer declarations */
const int exitcode = -1;
float arraylength = 0;
float angfreq = 0;
float* time = (float*)NULL;
float* output = (float*)NULL;
float ysinesum = 0;
float ycossum = 0;
float sumy = 0;
float acoef = 0;
float bcoef = 0;
float ccoef = 0;
int count = 0;

/* Input section */
printf("How many pairs of data are available?");
scanf("%f", &arraylength);
if(arraylength<1) {
printf("Invalid array length\n");
exit(exitcode);
}
printf("Enter the angular frequency: ");
scanf("%f", &angfreq);

for(count = 0;count<=(arraylength-1);count++) {
printf("Enter the time for entry %d: ",count);
scanf("%f", &time[count]);
printf("Enter the output cooresponding to t = %d: ", count);
scanf("%f", &output[count]);
}

/* Calculation Section */
for(count = 0;count<=(arraylength-1);count++) {
sumy = sumy + output[count];
ysinesum = ysinesum + output[count]*sin(angfreq*time[count]);
ycossum = ycossum + output[count]*cos(angfreq*time[count]);
}

acoef = sumy / (arraylength - 1);
bcoef = (2/(arraylength - 1)) * ycossum;
ccoef = (2/(arraylength - 1)) * ysinesum;

/* Output Section */
printf("The equation of the sinusoid is: \n");
printf("%3.3f + %3.3f cos(%3.3f t) + %3.3f sin(%3.3f t)\n");
return 0;
}

Thanks,
Dave

Jan 9 '07 #1
37 7094
dm******@cox.net <dm******@cox.netwrote:
I am a mathematician trying to write a program in C to do some curve
fitting. When I get to the point where I attempt to enter data in my
arrays, I get a General Protection Exception error message. What is
this and how can I fix it. I am writing in Turbo C++. My source code is
below.
I realize that being a mathematician you won't care about some of the
advice I'll give you, but you should if you want to use C properly in
the future:
>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
use: int main(void)
{
/* Integer declarations */
const int exitcode = -1;
float arraylength = 0;
float angfreq = 0;
float* time = (float*)NULL;
float* output = (float*)NULL;
no need for the casts.
float ysinesum = 0;
float ycossum = 0;
float sumy = 0;
float acoef = 0;
float bcoef = 0;
float ccoef = 0;
int count = 0;

/* Input section */
printf("How many pairs of data are available?");
scanf("%f", &arraylength);
if(arraylength<1) {
printf("Invalid array length\n");
exit(exitcode);
}
printf("Enter the angular frequency: ");
scanf("%f", &angfreq);
It is a good idea to check the value returned by scanf to make sure it
read properly.
>
for(count = 0;count<=(arraylength-1);count++) {
printf("Enter the time for entry %d: ",count);
scanf("%f", &time[count]);
You did not allocate memory for time which is of type pointer to float
and is initialized to NULL. You are trying to write in a place that
doesn't belong to you. This is, probably, the reason for your error,
although I don't remember what the error means in Turbo C. Protection
Exception makes me believe that's something related to your attempt to
write where you shouldn't.
To allocate space for arraylength elements you should use this:
time=malloc(arraylength*sizeof(double))
or
time=malloc(arraylength*sizeof*arraylength)
then you should check and make sure the memory was allocated:
if(time==NULL) {
printf("Oooops");
/* ... add code to handle the allocation problem */
/* probably to cleanup and exit */
}

If everything goes well, do not forget to free the memory allocated by
malloc.

The same goes lower with output.
printf("Enter the output cooresponding to t = %d: ", count);
scanf("%f", &output[count]);
Same mistake as above. You didn't allocate memory for output.
}

/* Calculation Section */
for(count = 0;count<=(arraylength-1);count++) {
sumy = sumy + output[count];
ysinesum = ysinesum + output[count]*sin(angfreq*time[count]);
ycossum = ycossum + output[count]*cos(angfreq*time[count]);
}
You're using output although it doesn't have memory allocated for it.
Your program probably doesn't get here, anyway.
>
acoef = sumy / (arraylength - 1);
bcoef = (2/(arraylength - 1)) * ycossum;
ccoef = (2/(arraylength - 1)) * ysinesum;
You should test for correct input for arraylength, otherwise you may
have surprises when you divide by 0.
--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)

Jan 9 '07 #2
On 8 Jan 2007 18:55:30 -0800, "dm******@cox.net" <dm******@cox.net>
wrote:
>I am a mathematician trying to write a program in C to do some curve
fitting. When I get to the point where I attempt to enter data in my
arrays, I get a General Protection Exception error message. What is
this and how can I fix it. I am writing in Turbo C++. My source code is
below.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
/* Integer declarations */
const int exitcode = -1;
It would be more portable to remove this and use EXIT_FAILURE as the
argument to exit().
> float arraylength = 0;
It is a bit unusual to use a float to hold the number of elements of
an array.
> float angfreq = 0;
float* time = (float*)NULL;
First, remove the casts. They serve no purpose.

Each of these pointers is initialized to point to "nowhere". In
particular, they do not point to memory you own or have legal access
to. You cannot extract data from where they point nor can you store
data there. Since the pointers are initialized, you can test them for
equality with other pointers or pointer constants, but you may not
perform arithmetic on them.
> float* output = (float*)NULL;
float ysinesum = 0;
float ycossum = 0;
float sumy = 0;
float acoef = 0;
float bcoef = 0;
float ccoef = 0;
int count = 0;

/* Input section */
printf("How many pairs of data are available?");
scanf("%f", &arraylength);
if(arraylength<1) {
printf("Invalid array length\n");
exit(exitcode);
}
printf("Enter the angular frequency: ");
scanf("%f", &angfreq);

for(count = 0;count<=(arraylength-1);count++) {
printf("Enter the time for entry %d: ",count);
scanf("%f", &time[count]);
Here you violate all those restrictions. The expression &time[count]
is identical to the expression time+count. This is not a valid
address. And then you expect scanf to store something at that
address.

Before you can use time to reference an array of values, you must
initialize it so that it points to memory you can use. The
traditional method is
time = malloc(arraylength * sizeof *time);

This will, if it succeeds, allocate a contiguous block of memory
capable of holding arraylength objects, each of which is the size of
the object type time points to, in this case float.

You should always check to see if malloc succeeded by testing the
return value against NULL.
> printf("Enter the output cooresponding to t = %d: ", count);
scanf("%f", &output[count]);
Ditto.
> }

/* Calculation Section */
for(count = 0;count<=(arraylength-1);count++) {
sumy = sumy + output[count];
ysinesum = ysinesum + output[count]*sin(angfreq*time[count]);
ycossum = ycossum + output[count]*cos(angfreq*time[count]);
}

acoef = sumy / (arraylength - 1);
bcoef = (2/(arraylength - 1)) * ycossum;
ccoef = (2/(arraylength - 1)) * ysinesum;

/* Output Section */
printf("The equation of the sinusoid is: \n");
printf("%3.3f + %3.3f cos(%3.3f t) + %3.3f sin(%3.3f t)\n");
Each of the %3.3f terms in the format string means there must be a
corresponding argument following the string which evaluates to a
double. You don't have any arguments after the string. It is OK to
use a float value because such values are promoted to double when
passed to printf.
> return 0;
}

Thanks,
Dave

Remove del for email
Jan 9 '07 #3
On Tue, 09 Jan 2007 03:31:55 +0000, Nelu wrote:
dm******@cox.net <dm******@cox.netwrote:
>I am a mathematician trying to write a program in C to do some curve
fitting. When I get to the point where I attempt to enter data in my
arrays, I get a General Protection Exception error message. What is
this and how can I fix it. I am writing in Turbo C++. My source code is
below.

I realize that being a mathematician you won't care about some of the
advice I'll give you,
Didn't your mummy teach you to leave your prejudices at home? Or
perhaps you are so small minded that just can't?
Jan 9 '07 #4

Barry Schwarz wrote:
On 8 Jan 2007 18:55:30 -0800, "dm******@cox.net" <dm******@cox.net>
wrote:
I am a mathematician trying to write a program in C to do some curve
fitting. When I get to the point where I attempt to enter data in my
arrays, I get a General Protection Exception error message. What is
this and how can I fix it. I am writing in Turbo C++. My source code is
below.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
/* Integer declarations */
const int exitcode = -1;

It would be more portable to remove this and use EXIT_FAILURE as the
argument to exit().
float arraylength = 0;

It is a bit unusual to use a float to hold the number of elements of
an array.
float angfreq = 0;
float* time = (float*)NULL;

First, remove the casts. They serve no purpose.

Each of these pointers is initialized to point to "nowhere". In
particular, they do not point to memory you own or have legal access
to. You cannot extract data from where they point nor can you store
data there. Since the pointers are initialized, you can test them for
equality with other pointers or pointer constants, but you may not
perform arithmetic on them.
float* output = (float*)NULL;
float ysinesum = 0;
float ycossum = 0;
float sumy = 0;
float acoef = 0;
float bcoef = 0;
float ccoef = 0;
int count = 0;

/* Input section */
printf("How many pairs of data are available?");
scanf("%f", &arraylength);
if(arraylength<1) {
printf("Invalid array length\n");
exit(exitcode);
}
printf("Enter the angular frequency: ");
scanf("%f", &angfreq);

for(count = 0;count<=(arraylength-1);count++) {
printf("Enter the time for entry %d: ",count);
scanf("%f", &time[count]);

Here you violate all those restrictions. The expression &time[count]
is identical to the expression time+count. This is not a valid
address. And then you expect scanf to store something at that
address.

Before you can use time to reference an array of values, you must
initialize it so that it points to memory you can use. The
traditional method is
time = malloc(arraylength * sizeof *time);

This will, if it succeeds, allocate a contiguous block of memory
capable of holding arraylength objects, each of which is the size of
the object type time points to, in this case float.

You should always check to see if malloc succeeded by testing the
return value against NULL.
printf("Enter the output cooresponding to t = %d: ", count);
scanf("%f", &output[count]);

Ditto.
}

/* Calculation Section */
for(count = 0;count<=(arraylength-1);count++) {
sumy = sumy + output[count];
ysinesum = ysinesum + output[count]*sin(angfreq*time[count]);
ycossum = ycossum + output[count]*cos(angfreq*time[count]);
}

acoef = sumy / (arraylength - 1);
bcoef = (2/(arraylength - 1)) * ycossum;
ccoef = (2/(arraylength - 1)) * ysinesum;

/* Output Section */
printf("The equation of the sinusoid is: \n");
printf("%3.3f + %3.3f cos(%3.3f t) + %3.3f sin(%3.3f t)\n");

Each of the %3.3f terms in the format string means there must be a
corresponding argument following the string which evaluates to a
double. You don't have any arguments after the string. It is OK to
use a float value because such values are promoted to double when
passed to printf.
return 0;
}

Thanks,
Dave


Remove del for email
Thanks for all of your replies; this is the first major program I've
written since I've gotten my degree in math. I will look at these again
tomorrow when I look at it again. I think I really need to get a better
background in C; I only took one programming class in college.

Dave

Jan 9 '07 #5
J. Sommers <js******@sessrimnir.netwrote:
On Tue, 09 Jan 2007 03:31:55 +0000, Nelu wrote:
>dm******@cox.net <dm******@cox.netwrote:
>>I am a mathematician trying to write a program in C to do some curve
fitting. When I get to the point where I attempt to enter data in my
arrays, I get a General Protection Exception error message. What is
this and how can I fix it. I am writing in Turbo C++. My source code is
below.

I realize that being a mathematician you won't care about some of the
advice I'll give you,

Didn't your mummy teach you to leave your prejudices at home? Or
perhaps you are so small minded that just can't?
It's not prejudice. I have friends that are mathematicians and none of
them cares about checking the return value of scanf, malloc, and any
other checks, in general. They usually rely on the fact that those
functions will not fail for their needs.
That's all.
I aplogize if I hurt anyone's feelings.

--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)

Jan 9 '07 #6
On 8 Jan 2007 18:55:30 -0800, "dm******@cox.net" <dm******@cox.net>
wrote in comp.lang.c:
I am a mathematician trying to write a program in C to do some curve
fitting. When I get to the point where I attempt to enter data in my
arrays, I get a General Protection Exception error message. What is
this and how can I fix it. I am writing in Turbo C++. My source code is
below.
There are so many things wrong with this program, meaning that you
have so many misunderstandings about C, that I will probably miss
some.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
/* Integer declarations */
const int exitcode = -1;
In C++ they often use const qualified objects to replace constant
expressions or literals, but this is not idiomatic in C, nor do C
compilers always optimize it as well.

Furthermore, returning -1 from main(), or passing it to exit(), is
non-standard and non-portable and the result is
implementation-defined. Much better, especially since you have
already included <stdlib.h>, is to use the standard and portable macro
EXIT_FAILURE to indicate unsuccessful program termination.
float arraylength = 0;
Given the way you use "arraylength" below, it should be an integer
type, not a floating point type.
float angfreq = 0;
float* time = (float*)NULL;
"time" is a legal, but ill-advised, name for an object at block scope.
The standard C library contains a function named time(), prototyped in
the header <time.h>, and that name is reserved at file scope. It is
not reserved inside a function, as you use it here, but might well
confuse a reader.
float* output = (float*)NULL;
The (float*) cast in the two initializations is completely unnecessary
and serves only to clutter your program and slightly obscure it.
Eliminate them. The placement of the asterisk suggests that you are
actually programming in C++, but the cast is not necessary there
either.
float ysinesum = 0;
float ycossum = 0;
float sumy = 0;
float acoef = 0;
float bcoef = 0;
float ccoef = 0;
int count = 0;

/* Input section */
printf("How many pairs of data are available?");
scanf("%f", &arraylength);
scanf() is a very poor choice to use for interactive user input, for a
variety of reasons. Not the least of which is the fact that the
behavior is undefined if the scanned text represents a value outside
the range of the destination type.
if(arraylength<1) {
printf("Invalid array length\n");
exit(exitcode);
Here is where you should have:
exit(EXIT_FAILURE);
printf("Enter the angular frequency: ");
scanf("%f", &angfreq);

for(count = 0;count<=(arraylength-1);count++) {
printf("Enter the time for entry %d: ",count);
scanf("%f", &time[count]);
Here's where your reap problem starts. You are asking scanf() to
write a value into time[copunt], but "time" is a null pointer, you
specifically initialized it that way. "time" does not point to any
floats, in fact it does not point to any valid memory that your
program can access.

When you try to write to memory through a null pointer, you produce
undefined behavior and under many modern operating systems, generate
some sort of fault that causes the OS to terminate your program.
printf("Enter the output cooresponding to t = %d: ", count);
scanf("%f", &output[count]);
}

/* Calculation Section */
for(count = 0;count<=(arraylength-1);count++) {
sumy = sumy + output[count];
ysinesum = ysinesum + output[count]*sin(angfreq*time[count]);
ycossum = ycossum + output[count]*cos(angfreq*time[count]);
}

acoef = sumy / (arraylength - 1);
bcoef = (2/(arraylength - 1)) * ycossum;
ccoef = (2/(arraylength - 1)) * ysinesum;

/* Output Section */
printf("The equation of the sinusoid is: \n");
printf("%3.3f + %3.3f cos(%3.3f t) + %3.3f sin(%3.3f t)\n");
return 0;
}
Somewhere after the definition of the pointers "time" and "output" and
getting a value for "count", you need to allocate memory to these
pointers to hold the values you want to store there.

Something like this:

time = malloc(count * sizeof *time);
output = malloc(count * sizeof *output);
if ((NULL == time) || (NULL == output))
{
printf("Memory allocation failure\n");
free(time);
free(output);
exit (EXIT_FAILURE);
}

And at the end of your program, before the perfectly correct "return
0;", you should add:

free(time);
free(output);

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jan 9 '07 #7

Nelu wrote:
J. Sommers <js******@sessrimnir.netwrote:
On Tue, 09 Jan 2007 03:31:55 +0000, Nelu wrote:
dm******@cox.net <dm******@cox.netwrote:
I am a mathematician trying to write a program in C to do some curve
fitting. When I get to the point where I attempt to enter data in my
arrays, I get a General Protection Exception error message. What is
this and how can I fix it. I am writing in Turbo C++. My source code is
below.

I realize that being a mathematician you won't care about some of the
advice I'll give you,
Didn't your mummy teach you to leave your prejudices at home? Or
perhaps you are so small minded that just can't?

It's not prejudice. I have friends that are mathematicians and none of
them cares about checking the return value of scanf, malloc, and any
other checks, in general. They usually rely on the fact that those
functions will not fail for their needs.
That's all.
I aplogize if I hurt anyone's feelings.

--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
None taken; I really think that a programming class should've been
required for my math degree. I took it as part of my other degree
(meteorology).

Dave

Jan 9 '07 #8
"dm******@cox.net" wrote:
>
I am a mathematician trying to write a program in C to do some curve
fitting. When I get to the point where I attempt to enter data in my
arrays, I get a General Protection Exception error message. What is
this and how can I fix it. I am writing in Turbo C++. My source code
is below.
.... snip code ...

Your code is apparently C, not C++.

After passing your code through indent to eliminate the excessive
indentation etc. and make it readable, I compiled it. An obvious
error is the value of errorcode, which can only be 0, EXIT_SUCCESS,
or EXIT_FAILURE. Similarly casting NULL to float is evil. If you
want 0.0 say so. Casts are always suspect, and probably errors.
I see no sign of allocation of the arrays, which I suspect should
exist because of the presence of the variable arraylength (and why
should that be a float?). Just a cursory look.

Results follow:

junk.c: In function `main':
junk.c:53: warning: too few arguments for format

The line involved is the last printf.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
/* Integer declarations */
const int exitcode = -1;
float arraylength = 0;
float angfreq = 0;
float *time = (float *)NULL;
float *output = (float *)NULL;
float ysinesum = 0;
float ycossum = 0;
float sumy = 0;
float acoef = 0;
float bcoef = 0;
float ccoef = 0;
int count = 0;

/* Input section */
printf("How many pairs of data are available?");
scanf("%f", &arraylength);
if (arraylength < 1) {
printf("Invalid array length\n");
exit(exitcode);
}
printf("Enter the angular frequency: ");
scanf("%f", &angfreq);

for (count = 0; count <= (arraylength - 1); count++) {
printf("Enter the time for entry %d: ", count);
scanf("%f", &time[count]);
printf("Enter the output cooresponding to t = %d: ", count);
scanf("%f", &output[count]);
}

/* Calculation Section */
for (count = 0; count <= (arraylength - 1); count++) {
sumy = sumy + output[count];
ysinesum = ysinesum +
output[count] * sin(angfreq * time[count]);
ycossum = ycossum +
output[count] * cos(angfreq * time[count]);
}

acoef = sumy / (arraylength - 1);
bcoef = (2 / (arraylength - 1)) * ycossum;
ccoef = (2 / (arraylength - 1)) * ysinesum;

/* Output Section */
printf("The equation of the sinusoid is: \n");
printf("%3.3f + %3.3f cos(%3.3f t) + %3.3f sin(%3.3f t)\n");
return 0;
}

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
Jan 9 '07 #9

Jack Klein wrote:
On 8 Jan 2007 18:55:30 -0800, "dm******@cox.net" <dm******@cox.net>
wrote in comp.lang.c:
I am a mathematician trying to write a program in C to do some curve
fitting. When I get to the point where I attempt to enter data in my
arrays, I get a General Protection Exception error message. What is
this and how can I fix it. I am writing in Turbo C++. My source code is
below.

There are so many things wrong with this program, meaning that you
have so many misunderstandings about C, that I will probably miss
some.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
/* Integer declarations */
const int exitcode = -1;

In C++ they often use const qualified objects to replace constant
expressions or literals, but this is not idiomatic in C, nor do C
compilers always optimize it as well.

Furthermore, returning -1 from main(), or passing it to exit(), is
non-standard and non-portable and the result is
implementation-defined. Much better, especially since you have
already included <stdlib.h>, is to use the standard and portable macro
EXIT_FAILURE to indicate unsuccessful program termination.
float arraylength = 0;

Given the way you use "arraylength" below, it should be an integer
type, not a floating point type.
float angfreq = 0;
float* time = (float*)NULL;

"time" is a legal, but ill-advised, name for an object at block scope.
The standard C library contains a function named time(), prototyped in
the header <time.h>, and that name is reserved at file scope. It is
not reserved inside a function, as you use it here, but might well
confuse a reader.
float* output = (float*)NULL;

The (float*) cast in the two initializations is completely unnecessary
and serves only to clutter your program and slightly obscure it.
Eliminate them. The placement of the asterisk suggests that you are
actually programming in C++, but the cast is not necessary there
either.
float ysinesum = 0;
float ycossum = 0;
float sumy = 0;
float acoef = 0;
float bcoef = 0;
float ccoef = 0;
int count = 0;

/* Input section */
printf("How many pairs of data are available?");
scanf("%f", &arraylength);

scanf() is a very poor choice to use for interactive user input, for a
variety of reasons. Not the least of which is the fact that the
behavior is undefined if the scanned text represents a value outside
the range of the destination type.
if(arraylength<1) {
printf("Invalid array length\n");
exit(exitcode);

Here is where you should have:
exit(EXIT_FAILURE);
printf("Enter the angular frequency: ");
scanf("%f", &angfreq);

for(count = 0;count<=(arraylength-1);count++) {
printf("Enter the time for entry %d: ",count);
scanf("%f", &time[count]);

Here's where your reap problem starts. You are asking scanf() to
write a value into time[copunt], but "time" is a null pointer, you
specifically initialized it that way. "time" does not point to any
floats, in fact it does not point to any valid memory that your
program can access.

When you try to write to memory through a null pointer, you produce
undefined behavior and under many modern operating systems, generate
some sort of fault that causes the OS to terminate your program.
printf("Enter the output cooresponding to t = %d: ", count);
scanf("%f", &output[count]);
}

/* Calculation Section */
for(count = 0;count<=(arraylength-1);count++) {
sumy = sumy + output[count];
ysinesum = ysinesum + output[count]*sin(angfreq*time[count]);
ycossum = ycossum + output[count]*cos(angfreq*time[count]);
}

acoef = sumy / (arraylength - 1);
bcoef = (2/(arraylength - 1)) * ycossum;
ccoef = (2/(arraylength - 1)) * ysinesum;

/* Output Section */
printf("The equation of the sinusoid is: \n");
printf("%3.3f + %3.3f cos(%3.3f t) + %3.3f sin(%3.3f t)\n");
return 0;
}

Somewhere after the definition of the pointers "time" and "output" and
getting a value for "count", you need to allocate memory to these
pointers to hold the values you want to store there.

Something like this:

time = malloc(count * sizeof *time);
output = malloc(count * sizeof *output);
if ((NULL == time) || (NULL == output))
{
printf("Memory allocation failure\n");
free(time);
free(output);
exit (EXIT_FAILURE);
}

And at the end of your program, before the perfectly correct "return
0;", you should add:

free(time);
free(output);

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Thanks, Jack. Bear with me as I am relearning a lot of this. I got away
with not having to program for about a year and a half after I got my
degree so I'm probably due.

Dave

Jan 9 '07 #10
J. Sommers wrote:
>I realize that being a mathematician you won't care about some of the
advice I'll give you,

Didn't your mummy teach you to leave your prejudices at home? Or
perhaps you are so small minded that just can't?
Such prejudices usually don't develop until after you are forced to work
with mathematicians, then they aren't so much prejudices as judgements.
Jan 9 '07 #11
Jack Klein wrote:
> float arraylength = 0;

Given the way you use "arraylength" below, it should be an integer
type, not a floating point type.
A number of people have said this, but by itself it's misleading. The
OP later uses arraylength in expressions that are intended to be float
valued:
> bcoef = (2/(arraylength - 1)) * ycossum;
ccoef = (2/(arraylength - 1)) * ysinesum;
If he declares arraylength as an int, the subexpression

2 / ( arraylength - 1 )

will be evaluated using integer arithmetic, and will have the value 0
for arraylength 3.

Assuming an arraylength declared as an int, the subexpression must be
coerced to a floating-point type. Either

2 / (( float ) arraylength - 1 )

or

2.0 / ( arraylength - 1 )

Or he could rearrange the full expression:

bcoef = ycossum * 2 / ( arraylength - 1 );

In this case, as long as ycossum is a floating-point type, the entire
expression, written in this order, is evaluated in floating-point.

Making arraylength an int is the right thing to do, but you also have to
account for the numerical consequences.

- Ernie http://home.comcast.net/~erniew
Jan 9 '07 #12
dm******@cox.net wrote:
I am a mathematician trying to write a program in C to do some curve
fitting. When I get to the point where I attempt to enter data in my
arrays, I get a General Protection Exception error message. What is
this and how can I fix it.
A GPF (general protection fault) is what happens on x86-based machines
when your program does something it's not allowed to do, and by far the
most common cause is trying to access memory that doesn't belong to you.

In your program, you declare a couple of pointers,
float* time = (float*)NULL;
float* output = (float*)NULL;
and later try to store some numbers in the memory they point to,
scanf("%f", &time[count]);
scanf("%f", &output[count]);
but since you didn't actually allocate any memory for them, they don't
point to anywhere.

A couple of observations in addition to the ones others have already made:

scanf() can be a minefield. An alternative that's often better is to use
something like fgets() in a custom function. For example,

int enter_int( void )
{
char buf[ 80 ];

fgets( buf, sizeof buf, stdin );
return atoi( buf );
}

You can make this as fancy as you want, and all the extra work remains in
this one function, no matter how many times you need to get an input from
the user. It could print the prompt and enforce range restrictions:

int enter_int( char *prompt, int lo, int hi )
{
char buf[ 80 ];
int i;

while ( 1 ) {
printf( "%s\n", prompt );
fgets( buf, sizeof buf, stdin );
i = atoi( buf );
if ( i >= lo && i <= hi )
return i;
printf( "The number must be between %d and %d.\n", lo, hi );
}
}

Or it could optionally get the input from any stream, e.g. a data file,
rather than solely from the user.

int enter_int( FILE *fp )
{
char buf[ 80 ];

fgets( buf, sizeof buf, fp );
return atoi( buf );
}
for(count = 0;count<=(arraylength-1);count++) {
The more common and concise idiom for this is

for ( count = 0; count < arraylength; count++ ) {
sumy = sumy + output[count];
C allows you to write this more concisely as

sumy += output[ count ];

Whichever way you write it, beware of the numerical behavior of this
kind of accumulation. In the worst case, roundoff error can grow at
each iteration. Consider the following program.

#include <stdio.h>

int main( void )
{
float f = 1000.0;
int i;

for ( i = 0; i < 1000; i++ )
f += 0.1;
printf( "%.6f\n", f );
return 0;
}

You might expect this to print "1100.000000", but in reality it prints
"1099.975586" (typically).
printf("The equation of the sinusoid is: \n");
printf("%3.3f + %3.3f cos(%3.3f t) + %3.3f sin(%3.3f t)\n");
If the intent is simply to print the number with 3 decimal places, you
don't need the width component of the format specifier. In other words,
rather than "%3.3f", you only need "%.3f".

- Ernie http://home.comcast.net/~erniew
Jan 9 '07 #13
On Tue, 09 Jan 2007 04:00:10 +0000, Nelu wrote:
J. Sommers <js******@sessrimnir.netwrote:
>On Tue, 09 Jan 2007 03:31:55 +0000, Nelu wrote:
>>dm******@cox.net <dm******@cox.netwrote:
I am a mathematician trying to write a program in C to do some curve
fitting. When I get to the point where I attempt to enter data in my
arrays, I get a General Protection Exception error message. What is
this and how can I fix it. I am writing in Turbo C++. My source code is
below.

I realize that being a mathematician you won't care about some of the
advice I'll give you,

Didn't your mummy teach you to leave your prejudices at home? Or
perhaps you are so small minded that just can't?

It's not prejudice.
It is prejudice.
I have friends that are mathematicians and none of them cares about
checking the return value of scanf, malloc, and any other checks, in
general.
How many friends do you have that are mathematicians? Ten? Twenty? How
does that compare with the thousands of mathematicians world over? Even
those ten or twenty systematically, and in every single occasion were to
ignore your advice that would not imply that all mathematicians would (but
it would probably imply that there is something systematically weird with
your advice).

I also have a number a software engineer friends who entertain astounding
superstitions, but that is no evidence that all software engineers do so.
You just can't generalize from such small samples and anecdotal evidence.
They usually rely on the fact that those functions will not
fail for their needs. That's all.
Which might be a sensible thing to do for them. C purity and perfection
might be your goal, but other people will just want their little C code to
run well enough to solve their problem, even if, say, they use

int main()

rather than

int main(int argc, char **argv)

I aplogize if I hurt anyone's feelings.
Those who have the guts to apologize in public tend to be a cut above the
rest. Kudos to you. Just remember to keep your prejudices in check. We all
have prejudices - otherwise we could not make sense of a world where
information is almost always incomplete.
Jan 9 '07 #14
Ivar Rosquist said:

<snip>
You just can't generalize from such small samples and anecdotal evidence.
Oh yes he can - as he just proved. :-)

<snip>

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Jan 9 '07 #15
Ivar Rosquist <IR*******@irq.orgwrote:
On Tue, 09 Jan 2007 04:00:10 +0000, Nelu wrote:
>J. Sommers <js******@sessrimnir.netwrote:
>>On Tue, 09 Jan 2007 03:31:55 +0000, Nelu wrote:

dm******@cox.net <dm******@cox.netwrote:
I am a mathematician trying to write a program in C to do some curve
fitting. When I get to the point where I attempt to enter data in my
arrays, I get a General Protection Exception error message. What is
this and how can I fix it. I am writing in Turbo C++. My source code is
below.

I realize that being a mathematician you won't care about some of the
advice I'll give you,

Didn't your mummy teach you to leave your prejudices at home? Or
perhaps you are so small minded that just can't?

It's not prejudice.

It is prejudice.
Ok. Although, combining my (limited) experience with the lack of checks in
the OP's code I don't think it should have come out that way. But that's
just my opinion, of course.
>I have friends that are mathematicians and none of them cares about
checking the return value of scanf, malloc, and any other checks, in
general.

How many friends do you have that are mathematicians? Ten? Twenty? How
does that compare with the thousands of mathematicians world over? Even
those ten or twenty systematically, and in every single occasion were to
ignore your advice that would not imply that all mathematicians would (but
it would probably imply that there is something systematically weird with
your advice).

I also have a number a software engineer friends who entertain astounding
superstitions, but that is no evidence that all software engineers do so.
You just can't generalize from such small samples and anecdotal evidence.
>They usually rely on the fact that those functions will not
fail for their needs. That's all.

Which might be a sensible thing to do for them. C purity and perfection
might be your goal, but other people will just want their little C code to
run well enough to solve their problem, even if, say, they use

int main()

rather than

int main(int argc, char **argv)

This is why I said what I said. I should have probably said 'you may not
care' instead of 'you won't care' and I specified 'some of the advice'
because it 'might be a sensible thing to do for them' to do things the
way they see fit. I did not indent to say anything that may be
considered prejudiced or hurtful in any way. I am really sorry if it
came out that way.
>I aplogize if I hurt anyone's feelings.

Those who have the guts to apologize in public tend to be a cut above the
rest. Kudos to you. Just remember to keep your prejudices in check. We all
have prejudices - otherwise we could not make sense of a world where
information is almost always incomplete.
--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)

Jan 9 '07 #16
On Tue, 09 Jan 2007 16:38:25 GMT, Ivar Rosquist <IR*******@irq.org>
wrote:
>It's not prejudice.

It is prejudice.
In general, programmers are more interested in programming than in
mathematics. In general, mathematicians are more interested in
mathematics than programming.

If that's prejudice, so be it.

--
Al Balmer
Sun City, AZ
Jan 9 '07 #17
Al Balmer said:
On Tue, 09 Jan 2007 16:38:25 GMT, Ivar Rosquist <IR*******@irq.org>
wrote:
>>It's not prejudice.

It is prejudice.

In general, programmers are more interested in programming than in
mathematics. In general, mathematicians are more interested in
mathematics than programming.
They're different states of the same element. Mathematics is frozen
programming. (Or, if you prefer, programming is defrosted mathematics.)

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Jan 9 '07 #18
Nelu wrote:
J. Sommers <js******@sessrimnir.netwrote:
>On Tue, 09 Jan 2007 03:31:55 +0000, Nelu wrote:
>>dm******@cox.net <dm******@cox.netwrote:
I am a mathematician trying to write a program in C to do some curve
fitting. When I get to the point where I attempt to enter data in my
arrays, I get a General Protection Exception error message. What is
this and how can I fix it. I am writing in Turbo C++. My source code is
below.
I realize that being a mathematician you won't care about some of the
advice I'll give you,
Didn't your mummy teach you to leave your prejudices at home? Or
perhaps you are so small minded that just can't?

It's not prejudice. I have friends that are mathematicians and none of
them cares about checking the return value of scanf, malloc, and any
other checks, in general. They usually rely on the fact that those
functions will not fail for their needs.
That's all.
I aplogize if I hurt anyone's feelings.
*shrug* I know a graph theorist and he always listen to advice
regarding clean coding.

People from all walks of life ignore returns from malloc(), at al. Even
coders, which is evident from the constant stream of examples to this
very newsgroup.
Jan 9 '07 #19
Richard Heathfield wrote:
Al Balmer said:
>On Tue, 09 Jan 2007 16:38:25 GMT, Ivar Rosquist <IR*******@irq.org>
wrote:
>>>It's not prejudice.
It is prejudice.
In general, programmers are more interested in programming than in
mathematics. In general, mathematicians are more interested in
mathematics than programming.

They're different states of the same element. Mathematics is frozen
programming. (Or, if you prefer, programming is defrosted mathematics.)
So, if you leave your math alone for too long, does it become freezer burnt?
Jan 9 '07 #20
On Tue, 09 Jan 2007 17:10:25 +0000, Richard Heathfield wrote:
Ivar Rosquist said:

<snip>
>You just can't generalize from such small samples and anecdotal evidence.

Oh yes he can - as he just proved. :-)
Pray tell us: What exactly has been proved?
Jan 9 '07 #21
On Tue, 09 Jan 2007 18:28:24 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote:
>Al Balmer said:
>On Tue, 09 Jan 2007 16:38:25 GMT, Ivar Rosquist <IR*******@irq.org>
wrote:
>>>It's not prejudice.

It is prejudice.

In general, programmers are more interested in programming than in
mathematics. In general, mathematicians are more interested in
mathematics than programming.

They're different states of the same element. Mathematics is frozen
programming. (Or, if you prefer, programming is defrosted mathematics.)
Of course, and both are simply manifestations of the sex drive.

--
Al Balmer
Sun City, AZ
Jan 9 '07 #22
Ivar Rosquist said:
On Tue, 09 Jan 2007 17:10:25 +0000, Richard Heathfield wrote:
>Ivar Rosquist said:

<snip>
>>You just can't generalize from such small samples and anecdotal
evidence.

Oh yes he can - as he just proved. :-)

Pray tell us: What exactly has been proved?
He has proved that he can generalise from small samples and anecdotal
evidence. All humans can do this.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Jan 9 '07 #23
On Tue, 09 Jan 2007 19:30:15 +0000, Richard Heathfield wrote:
Ivar Rosquist said:
>On Tue, 09 Jan 2007 17:10:25 +0000, Richard Heathfield wrote:
>>Ivar Rosquist said:

<snip>

You just can't generalize from such small samples and anecdotal
evidence.

Oh yes he can - as he just proved. :-)

Pray tell us: What exactly has been proved?

He has proved that he can generalise from small samples and anecdotal
evidence. All humans can do this.
Oh, I see :-)
Jan 9 '07 #24
On Tue, 09 Jan 2007 16:38:25 GMT, in comp.lang.c , Ivar Rosquist
<IR*******@irq.orgwrote:
>On Tue, 09 Jan 2007 04:00:10 +0000, Nelu wrote:
>J. Sommers <js******@sessrimnir.netwrote:
>>>
Didn't your mummy teach you to leave your prejudices at home? Or
perhaps you are so small minded that just can't?

It's not prejudice.

It is prejudice.
Y'know, you guys ought to grow up. I don't see any actual
mathematicians complaining about Nelu implying they're not
programmers.
> How many friends do you have that are mathematicians?
Who the hell cares? It was a casual comment, not a bloody indictment
of a class. If you want to start moaning, why not complain about
something sensible, like the overpriced rubbish that Apple sell.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jan 9 '07 #25
On Tue, 09 Jan 2007 23:29:41 +0000, Mark McIntyre wrote:
On Tue, 09 Jan 2007 16:38:25 GMT, in comp.lang.c , Ivar Rosquist
<IR*******@irq.orgwrote:
>>On Tue, 09 Jan 2007 04:00:10 +0000, Nelu wrote:
>>J. Sommers <js******@sessrimnir.netwrote:

How many friends do you have that are mathematicians?

Who the hell cares? It was a casual comment, not a bloody indictment
of a class.
The OP has already apologized - no harm done.
If you want to start moaning, why not complain about
something sensible, like the overpriced rubbish that Apple sell.
This is WAY off topic, but kind of amusing. If you think that
Apple sells rubbish (overpriced or not) here is an idea for you to
explore: Don't buy Apple products.
Jan 10 '07 #26
On 8 Jan 2007 20:11:46 -0800, "dm******@cox.net" <dm******@cox.net>
wrote:
snip 150 lines
>Thanks, Jack. Bear with me as I am relearning a lot of this. I got away
with not having to program for about a year and a half after I got my
degree so I'm probably due.
Your next lesson is to learn to quote only relevant material. You
don't need to quote a whole message just to say thanks.
Remove del for email
Jan 10 '07 #27
<dm******@cox.netwrote in message
news:11**********************@42g2000cwt.googlegro ups.com...
>I am a mathematician trying to write a program in C to do some curve
fitting. When I get to the point where I attempt to enter data in my
arrays, I get a General Protection Exception error message. What is
this and how can I fix it. I am writing in Turbo C++. My source code is
below.
Just some general advice for you.

The other posters have pointed out the errors.

a)You might want to obtain the classic K&R book by Messrs. Kernighan and
Ritchie.

b)You might want to upgrade to Microsoft Visual C++. I understand it is
about $110 these days (a far cry from when Visual Studio used to be $1,500).
It is more current and has good help, both online and built in.

c)I don't want to discourage you from programming in 'C', but maybe a
scripting language with more "protection" (built into Mathematica?) would
be appropriate. 'C' compiles very efficiently, but you also need to be
careful: pointer errors, array subscripting errors, and mismatched function
arguments are deadly ... these translate into triggering memory protection
faults on the machine, mismatched stack frames, etc.

d)In general in 'C', you want to give the compiler all the information it
needs to check definitions against invocations. This means that you use
header files correctly to do this. (If this doesn't make sense, please
write me at dt*@e3ft.com and make it past my SPAM reply/ack process and I'll
send you more information.)

Dave.
Jan 10 '07 #28

Ivar Rosquist wrote:
On Tue, 09 Jan 2007 04:00:10 +0000, Nelu wrote:
J. Sommers <js******@sessrimnir.netwrote:
On Tue, 09 Jan 2007 03:31:55 +0000, Nelu wrote:

I realize that being a mathematician you won't care about some of the
advice I'll give you,

Didn't your mummy teach you to leave your prejudices at home? Or
perhaps you are so small minded that just can't?
It's not prejudice.

It is prejudice.
I have friends that are mathematicians and none of them cares about
checking the return value of scanf, malloc, and any other checks, in
general.

How many friends do you have that are mathematicians? Ten? Twenty? How
does that compare with the thousands of mathematicians world over? Even
those ten or twenty systematically, and in every single occasion were to
ignore your advice that would not imply that all mathematicians would (but
it would probably imply that there is something systematically weird with
your advice).

I also have a number a software engineer friends who entertain astounding
superstitions, but that is no evidence that all software engineers do so.
You just can't generalize from such small samples and anecdotal evidence.
They usually rely on the fact that those functions will not
fail for their needs. That's all.

Which might be a sensible thing to do for them.
Which I took to be Nelu's point.

Jan 10 '07 #29
Richard Heathfield wrote:
Ivar Rosquist said:
>On Tue, 09 Jan 2007 17:10:25 +0000, Richard Heathfield wrote:
>>Ivar Rosquist said:

<snip>

You just can't generalize from such small samples and anecdotal
evidence.

Oh yes he can - as he just proved. :-)

Pray tell us: What exactly has been proved?

He has proved that he can generalise from small samples and anecdotal
evidence. All humans can do this.
"Everybody generalises from single examples. I know I do." Vlad Taltos,
probably in /Issola/ but I'm not sure and my Brust collection is at
home.

--
Chris "first on the Underground!" Dollin
"Reaching out for mirrors hidden in the web." - Renaissance, /Running Hard/

Jan 10 '07 #30
Clever Monkey <cl**************@hotmail.com.invalidwrote:
Richard Heathfield wrote:
Al Balmer said:
On Tue, 09 Jan 2007 16:38:25 GMT, Ivar Rosquist <IR*******@irq.org>
wrote:

It's not prejudice.
It is prejudice.
In general, programmers are more interested in programming than in
mathematics. In general, mathematicians are more interested in
mathematics than programming.
They're different states of the same element. Mathematics is frozen
programming. (Or, if you prefer, programming is defrosted mathematics.)
So, if you leave your math alone for too long, does it become freezer burnt?
No. It starts growing legs and walks out of the fridge, after having
eaten the cheese and leaving footprints in the butter.

(And then it starts infecting backdoored MS-Windows systems.)

Richard
Jan 10 '07 #31
Y'know, you guys ought to grow up. I don't see any actual
mathematicians complaining about Nelu implying they're not
programmers.
I don't see the big deal; I know I'm not a programmer and I don't claim
to be. I just thought being able to use C would help me with some of my
numerical calculations, which is most of my practice; I rarely do any
theoretical math.

Dave

Jan 10 '07 #32
In article <q6********************************@4ax.com>,
Mark McIntyre <ma**********@spamcop.netwrote:
>Y'know, you guys ought to grow up. I don't see any actual
mathematicians complaining about Nelu implying they're not
programmers.
According to my degree, I'm a Mathematician. Or a Scientist,
depending how you interpret the piece of paper. Either way,
I spend most of my time programming in some form or another
(and is configuring network equipment not a form of programming?)

Whatever it is you call me: of course I check the results of
malloc() and library routines. (Though admittedly, perhaps not
the result of -every- read or write when I'm coding up something
for my own use.)
--
There are some ideas so wrong that only a very intelligent person
could believe in them. -- George Orwell
Jan 10 '07 #33
>>>>"WR" == Walter Roberson <ro******@ibd.nrc-cnrc.gc.cawrites:

WRAccording to my degree, I'm a Mathematician.

According to my degree(s), I'm a musician. I'm not convinced that
that has any relevance.

Charlton
--
Charlton Wilbur
cw*****@chromatico.net
Jan 10 '07 #34

"Walter Roberson":
According to my degree, I'm a Mathematician. Or a Scientist,
depending how you interpret the piece of paper. Either way,
I spend most of my time programming in some form or another
(and is configuring network equipment not a form of programming?)

Whatever it is you call me: of course I check the results of
malloc() and library routines. (Though admittedly, perhaps not
the result of -every- read or write when I'm coding up something
for my own use.)
I'm always surprised by the programming acumen of mathematicians. Some use
a language like C as their stock and trade, using calculation to inform
their practice. Others don't. The prof I had for enumerative combinatorics
was proud that he had only hand written instructions to a Turing machine as
a grad student decades ago. I had a bet with a colleague of his that I
couldn't get him to compile a program. I have yet to collect.

Dr. Griess at Michigan calculated the order of the Fischer-Griess group
without the help of a computer (=10^54). Go figure. LS
Jan 10 '07 #35
On Wed, 10 Jan 2007 01:01:06 GMT, in comp.lang.c , Ivar Rosquist
<IR*******@irq.orgwrote:
>If you think that
Apple sells rubbish (overpriced or not) here is an idea for you to
explore: Don't buy Apple products.
Thanks for the tip, once someone starts making Indesign and Quark
(that work) for some other platform. I'll have a choice.

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jan 11 '07 #36
Mark McIntyre <ma**********@spamcop.netwrote:
On Wed, 10 Jan 2007 01:01:06 GMT, in comp.lang.c , Ivar Rosquist
<IR*******@irq.orgwrote:
If you think that
Apple sells rubbish (overpriced or not) here is an idea for you to
explore: Don't buy Apple products.

Thanks for the tip, once someone starts making Indesign and Quark
(that work) for some other platform.
Indesign for M$ Windows works. IME. (I spent most of this week using
it.)

Richard
Jan 11 '07 #37
On Thu, 11 Jan 2007 13:52:12 GMT, in comp.lang.c ,
rl*@hoekstra-uitgeverij.nl (Richard Bos) wrote:
>Mark McIntyre <ma**********@spamcop.netwrote:
>On Wed, 10 Jan 2007 01:01:06 GMT, in comp.lang.c , Ivar Rosquist
<IR*******@irq.orgwrote:
>If you think that
Apple sells rubbish (overpriced or not) here is an idea for you to
explore: Don't buy Apple products.

Thanks for the tip, once someone starts making Indesign and Quark
(that work) for some other platform.

Indesign for M$ Windows works. IME. (I spent most of this week using
it.)
<OT>
They both work fine independently. However from experience I can tell
you that the PC and Mac versions are subtly incompatible in ways which
only become apparent when you send something back to someone who uses
the Mac version , and the entire book reflows. Trust me, this is not a
cheap discovery...
<ot>
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jan 11 '07 #38

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: SteveS | last post by:
Hello all. This problem is stumping me.... I run a page called "default.aspx". For some reason when I execute this page, I get the error below. It seems to run through the entire code behind...
39
by: Antoon Pardon | last post by:
I was wondering how people would feel if the cmp function and the __cmp__ method would be a bit more generalised. The problem now is that the cmp protocol has no way to indicate two objects are...
0
by: Paiman Allage | last post by:
Hello all, I hope you can help me. I have developed an ".NET" application and started to deploy the application. However, I am haveing a problem, where when I compile the program on my laptop,...
3
by: Steve | last post by:
I have some general catch clauses in my app as follows: try { } catch(Exception ex) { } try
6
by: akmkat | last post by:
I have encoutered a problem "General Protection Exception" when trying to run this program, I need a help on a urgent basis: the code: #include <stdio.h> #include <stdlib.h> #define L 20...
2
by: akmkat | last post by:
When I try to compile the following code with N = 1024, "General Protection Exception" occurs, but wehn N < 20, there is no problem. I need N = 1024, what'll I do? Plz help anyone #include...
0
by: KhoaNguyen | last post by:
Hi, When i compiled these two source files, it gives me an error saying: Inaccesssible Due to its protection level. ------------Base Class----------------- using System; using...
1
by: manhquynh8x | last post by:
I am programming a data compession program. It is used to compress a text file. After run program, i see this message: Exception 13: General protection fault at o1A7.. The compiler is Turbo C++...
2
by: subhasree | last post by:
Hi, I am a student of mathematics and quite new to programming in C. I am trying to write a code to construct an array which at every step has to compare the value of the current element with all...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.