If you really must use a single field to represent multiple values, you could make the field one of the unsigned types, assign each value a bit and go from there.
e.g.
/* A represents bit 1, H represents bit 8 */
enum values { A,B,C,D,E,F,G,H };
struct person {
unsigned score;
...
}...
Not sure what you're asking exactly, but strcmp() returns 0 when its string are equal and a non-zero value when they are not. So given two strings, s1 and s2:
if (strcmp(s1,s2)==0)
puts("equal");
else if (strcmp(s1,s2)>0)
puts("s1 greater than s2");
else...
Function pointers are generally more useful in C than they are in C++. C++'s object-oriented facilities tend to provide better ways of solving the same kinds of problems that are solved using function pointers in C.
In C, there are many uses for them, so it's hard to answer your question in a...
It "works" on my compiler as well, though it emits a diagnostic telling me that main() returns int. The only portable definition for main() is either:
int main(void) { /* .. * / }
OR
int main(int argc,char **argv) { /* ... */ }
As a result, any conforming C compiler is allowed to...
Another variation on the seek method described above is to use mmap() (if it's available to you), which allows you to treat the contents of the file as an ordinary array of char. This might be easier and will probably be faster.
Russ
bobbitts@hotmail.com
http://home.earthlink.net/~bobbitts
It depends on how much your program knows about the data in the file. Is it guaranteed that the records are sorted in ascending order? Are the records all approximately the same length?
If your program knows these things, then it can seek to about where the record will be in the file (you can...
Here are the problems I found:
1. main() returns int, not void.
2. The prototype for print_details() and the function definition don't match.
3. Your scanf() call in get_details() should be:
scanf("%s",ptr->name);
scanf("%d", &ptr->identity);
4. In initial_screen() you...
That's not strictly true. An array doesn't become a pointer to its first element when it is the operand of the sizeof operator or the operand of the address operator. This is why (where a is an array and p is a pointer to the same type) sizeof(a)!=sizeof(p) and &a becomes a pointer to an array...
I don't think this is possible. The only way I'm aware of is to write the DLL in C and then call the functions exported by the DLL from VB (with the appropriate Declares).
Russ
bobbitts@hotmail.com
http://home.earthlink.net/~bobbitts
For memory leaks, see:
http://www.dmalloc.com
For profiling, see if you have gprof or prof (comes with the GCC compiler system).
There are many others, try a web search.
Russ
bobbitts@hotmail.com
http://home.earthlink.net/~bobbitts
Actually, sizeof(char) is guaranteed to be 1, so multiplying by sizeof(char) buys you nothing.
Russ
bobbitts@hotmail.com
http://home.earthlink.net/~bobbitts
Clearly, your program is doing something illegal, but we can only speculate on what it's doing in the absence of the source code.
Try posting a *small* compilable program that exhibits the problem.
Russ
bobbitts@hotmail.com
http://home.earthlink.net/~bobbitts
You'll want to change that loop to check for EOF, in case the user signals EOF before pressing Enter:
int gobble_stdin(void)
{
int c;
while ((c=getchar())!='\n' && c!=EOF)
;
}
In C, there isn't any defined behavior when fflush() is used on input streams. However, implementations...
The program looks fine. When you're running it inside VC++, are you sure you're entering the input in the IDE in exactly the same way you are when running it outside the IDE?
Russ
bobbitts@hotmail.com
http://home.earthlink.net/~bobbitts
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.