Need help locating a mistake in a single code line [closed] - c

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
void find_best_match(char*currword, char(*)[]chosen_dict ,char*newWord,int length_of_dict)
I get "expected "," ,";" or ")" before "chosen_dict" " . I've revised the syntax multiple times , but can't locate the error. Any help would be appreciated :)

This does not make any sense:
char(*)[]chosen_dict
A correct declaration would be
char(*chosen_dict)[]

The pointer to an unknown-sized array is:
char (*chosen_dict)[]
Some people find the "spiral rule" helpful for understanding the declaration. Others prefer typedefs, and others yet just use cdecl to figure this stuff out.
As long as you don't need to declare arrays of function pointers to functions taking pointers to arrays in one line, you should be fine.

Related

What is the special macro of buffer size in standard C library? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I saw this special macro when I read a source code. If I remember correctly, it is defined in the standard library.
The name of this macro is related to the buffer size, and in my machine its implementation is 1024.
Now I want to use it to initialize the buffer but I forgot what it is called.
So is there any one who can help me make my code look more professional?
If I don't know what I am looking for specifically, how can I clearly say what I need?
Are you talking about BUFSIZ? It's a macro provided by <stdio.h> and it expands to the size of the buffer used by setbuf().
I'm not sure what use it has in your own code.

Integer expression assignment to a variable from string - C [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm programming an OS.
So I want to know how can an expression like (2*(7+8)-9)+2 can be initialised into variable using user defined function like extract() :
extract(char a[])
{
//some code
}
char expr[] = "(2*(7+8)-9)+2";
int value = extract(expr);
I'm doing this for variable initialisation from string.( Any tips/ideas/suggestions? )
StackOverflow has already covered the topic of Infix expression parsing and Recursive Decent parsing using C++ here. Read it over to understand the algorithm, then see if you can convert it to C. That will definitely be "fun" and teach you a little bit about C along the way.

Displaying pointer's address in C, without using printf? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I need to recode the printf function using only a handful of functions from the libc library, namely write, malloc and free and a few other basic ones. The only formatting tab that I am having trouble with is %p as I have no idea how to display it using the write function, as passing the address of my pointer to a function that prints strings resulted in empty output. I have also tried typecasting it to a char * and unsigned char * but that did not work either. I have looked online but only found solutions invloving forbidden functions so I am not even sure where to begin.

C: recognize variable type [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm learning C. I wonder whether there is an instruction or command to recognize the type of the variable.
To be more practical: I have a program which works with integers, I want to show an error message if the user inserts a real number when running the program.
Hope you can help!
This is not part of the C standard, but GCC has the typeof keyword.
You have to be using the GCC compiler for it though.

Printf its variations and its prototype understanding [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Can anybody explain the variations in printf syntax..i am confused in some of it
like
printf(5+"hello my friend");//i have problem this addition of 5
printf("hello""my""friend");//i have problem with double apostrophe
what kind of printf prototype do these follows ?
Is this have anything to do with dynamic linking?
Can anybody show some other weird printfs and explain them.
A string in C is accessed via a pointer to a char (see H2CO3's comment for a more precise definition). If you add 5 to a pointer to a char, you start the string 5 characters later. So 5+"hello my friend" points to " my friend", skipping "hello".
When a C compiler sees two strings with nothing (except possibly whitespace) in between, it treats them as a single string. This makes it easier to break long strings in multiple lines.
So "hello""my""friend" compiles into exactly the same thing as "hellomyfriend" or
"hello"
"my"
"friend"
None of these has anything to do with printf, and a lot to do with strings.

Resources