Forum: C Jun 16th, 2009 |
| Replies: 6 Views: 290 The most natural place for structures without tags is typedef declaration (it's the only place I've used anonymous structs ;)):
typedef struct
{
...
} Record;
...
Record rec;
Record*... |
Forum: C Jun 12th, 2009 |
| Replies: 6 Views: 375 >...if you want to be a pedant...
To make distinctions between static, automatic and dynamic attributes - is it too pedantic for you?
;) |
Forum: C Jun 12th, 2009 |
| Replies: 8 Views: 826 In C you can assign void* type pointer value to the pointer of any type without casting. So simply declare a proper type pointer and set it to the buffer:
char* pchar = buf_ptr;
char* ptr = pchar... |
Forum: C Jun 12th, 2009 |
| Replies: 6 Views: 375 >short answer: static arrays are allocated when the function is called...
Short remark: static arrays are allocated before the first call of the function. However no static arrays in OP snippet.... |
Forum: C Jun 11th, 2009 |
| Replies: 7 Views: 581 The new-line character is defined in C, it's '\n'. The fgets standard library function retains a single new-line character from text mode streams only, but...
be careful: |
Forum: C Jun 11th, 2009 |
| Replies: 14 Views: 856 >Well I had seen it being limited in some early versions of cc gcc and all.
It was not the C language limit, it's a limit of the compiler (implementation),
>...Or atleast the method...
Generate a... |
Forum: C Jun 10th, 2009 |
| Replies: 7 Views: 770 A user-defined main() is not the first (and the only) function in the executable module. Have you ever heard about sturtup code? A console mode program has opened i/o streams - it's a job for startup... |
Forum: C Jun 10th, 2009 |
| Replies: 14 Views: 856 >Isn't 16 *'s maximum in C ???
I have never seen maximal values of translation limits were defined in C docs. |
Forum: C Jun 10th, 2009 |
| Replies: 18 Views: 862 >More random calls will tend to dilate the variance.
The variance of... what? We didn't estimate random sequence parameters in that case so the variance (or other moments) does not bear a relation... |
Forum: C Jun 9th, 2009 |
| Replies: 18 Views: 862 A day ago csurfer's algorithm solved the problem. That's "pipelined" version:
int i, j = rand()%20;
for (i = 0; i < 20; i++)
array[i] = (i != j)*(rand()%9 + 1);
In addition:... |
Forum: C Jun 9th, 2009 |
| Replies: 14 Views: 856 |
Forum: C Jun 8th, 2009 |
| Replies: 5 Views: 531 Why strncat? Make a single (expected) string by a single snprintf call. What's a problem? |
Forum: C Jun 7th, 2009 |
| Replies: 7 Views: 581 All except '\r' and (may be) quotes ;)
Do you really want to study C i/o basics on DaniWeb forum?
Better search for a good C i/o tutorial. There are lots of good links... |
Forum: C Jun 7th, 2009 |
| Replies: 14 Views: 856 The second argument type is a pointer to a pointer to FILE type.
Didn't you understand what's a pointer?
Evidently this function returns FILE* pointer via this argument. What's a strange... |
Forum: C Jun 7th, 2009 |
| Replies: 1 Views: 321 absread:
What's it: ancient TC non-standard function to read a sector from the HD in native DOS environment.
Usage: forget as soon as possible. |
Forum: C Jun 7th, 2009 |
| Replies: 6 Views: 418 Use fseek and ftell functions from <stdio.h>. |
Forum: C Jun 7th, 2009 |
| Replies: 11 Views: 657 Excuse me, siddhant3s: I have not seen your post above! :(
No need in my post now. |
Forum: C Jun 7th, 2009 |
| Replies: 11 Views: 657 According to the C and C++ standards
int array[....];
array[-2] - wrong expression, because array-2 points to inexisting array element (the only exception: pointer to the 1st element after... |
Forum: C Jun 7th, 2009 |
| Replies: 5 Views: 779 Now read why fflush(stdin) is wrong:
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1052863818&id=1043284351
and how to flush the input buffer in C:... |
Forum: C Jun 7th, 2009 |
| Replies: 4 Views: 350 >So, if you want to really use pointers pass all the pointers from the main function into the corresponding function.
It's too restrictive and unrealistic requirement.
>Even the pointer which you... |
Forum: C Jun 6th, 2009 |
| Replies: 4 Views: 350 >If i use float instead of double, i get the answer 25.628401 (which is wrong...
1. It's the same question as Why Cessna 182 can't be so fast as F-22?: float data type has precision ~6-7 decimal... |
Forum: C Jun 4th, 2009 |
| Replies: 11 Views: 654 No opened stdin and stdout streams in Win GDI applications (null pointers). You can't use scanf and printf functions in the program.
See, for example:... |
Forum: C Jun 3rd, 2009 |
| Replies: 3 Views: 578 Of course, it's possible (under your program "manual" contol). Open file in binary mode. Use fread and fwrite function. See fseek library function to set current write position and ftell to get it. |
Forum: C Jun 3rd, 2009 |
| Replies: 10 Views: 1,381 It seems you don't verify your list interface.
For example:
1. What's a role of the 1st insert_start parameter? You overwrite its value in the 1st statement of the function body then create new... |
Forum: C Jun 3rd, 2009 |
| Replies: 7 Views: 311 More precisely: if the program attempts to modify an array corresponding to a string literal, the behavior is undefined. |
Forum: C Jun 2nd, 2009 |
| Replies: 4 Views: 550 Can you put more specific question? How to...
- print a file to the same console window in parallel
- print a file to a new (console) window
- open then print a file from your (console) program... |
Forum: C Jun 2nd, 2009 |
| Replies: 9 Views: 491 Can you explain what is it: binary search tree sorted with quicksort method??? |
Forum: C Jun 1st, 2009 |
| Replies: 9 Views: 373 Well, let f(i) is i-th member without sign (it's not C).
f(i) = i/i! = i/(1*2*...*(i-1)*i) =
i/(i*(1*2...*(i-1)) = 1/(i-1)!
f(i+1) = 1/i! = 1/((i-1)!*i) = f(i)/i
i = 1, 2,... (0! = 1 by... |
Forum: C Jun 1st, 2009 |
| Replies: 9 Views: 373 See: you have fac > no for all no values because fac = n!. Therefore no/fac == 0 (integer division) and com=com+j is the same as com += 0...
1. Use double type for math calculations (not float).... |
Forum: C Jun 1st, 2009 |
| Replies: 10 Views: 571 >c is generally slow compared to other programming language.
>Just out of curiosity, what languages should be faster?
Assembler, fortran?
Look at these wonderful benchmarks:... |
Forum: C May 31st, 2009 |
| Replies: 3 Views: 314 Ooh, yet another grade supersystem...
Better try to search DaniWeb for grade. There are lots of dozens of grade calculation threads (solved;))... |
Forum: C May 30th, 2009 |
| Replies: 10 Views: 571 Good programmers are capable to write more effective programs practically in any programming languages than bad programmers can do it in machine codes ;) |
Forum: C May 28th, 2009 |
| Replies: 5 Views: 455 Better try to check it with your compiler.
Create test scenario(s): what to do - desired results. Write test driver, compile then run it. Compare results - and so on... |
Forum: C May 27th, 2009 |
| Replies: 6 Views: 845 From the C Standard:
None the less look at the link mentioned above. |
Forum: C May 27th, 2009 |
| Replies: 6 Views: 845 1. calloc, malloc, realloc et al: http://irc.essex.ac.uk/www.iota-six.co.uk/c/f7_dynamic_memory_allocation.asp (or lots of another tutorials on this topic).
2. (type)expression called cast. It... |
Forum: C May 26th, 2009 |
| Replies: 5 Views: 455 >still i am not able to understand how we can store the next node address in the current node.
Please, read my previous post again. And again. And again...
Nobody can store the next node address in... |
Forum: C May 26th, 2009 |
| Replies: 5 Views: 455 1. You may get 26-th character of readLine as readLine[26] - why sscanf(readLine+26...)?
2. Check input line length: may be no 26-th character in the line...
3. Why 'b' in +26 position corresponds... |
Forum: C May 26th, 2009 |
| Replies: 7 Views: 579 Of course, you have linker error because nobody (except you) knows such library function as concat (probably you want strcat).
The second attempt failed because fgets function puts the last '\n'... |
Forum: C May 26th, 2009 |
| Replies: 6 Views: 412 >Or do you know the 'ultimate' way?
Why not?
char* condense(char* s)
{
if (s) {
char* p = s;
char* q = s;
/* (never write so:) */
do if (*p != ' ') |
Forum: C May 26th, 2009 |
| Replies: 11 Views: 559 OK, Miracle or not Miracle - it's the other story...
You didn't answered the key question: what's is your problem?
Didn't you familiar with school-level arithmetics (where is conversion formula)?... |