Character functions vs string functions [closed] - c

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 just found a short code here, which would detect blank lines in a file. It used fgets() function in C library.
I wonder if character functions are better suited for files which have tabs, and perhaps continous spaces.
My qustion is what is the best way to parse a file for blank lines?

You can also use scanf(" %[^\n]s",string); in order to read spaces but fgets is best solution for your case.

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.

Remove spaces in batch variable [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 5 years ago.
Improve this question
So I have these two variables, a and c, they both have a space after them so when I'm trying to join them it prints "a c " and not "ac". How should I go on about removing the spaces?
set "a=%a: =%"
is one way. set the variable=%variablename:stringtoreplace=replacementstring%
The quotes ensure that any trailing spaces in the set line are not included into the value assigned.
The replacement string may be empty.
This is a general solution, replacing all strings matching stringtoreplace with the defined replacement.

Internals of ncurses: console input [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 6 years ago.
Improve this question
How exactly does Ncurses capture input into the console? I would like to implement it myself instead of using ncurses due to the overhead that ncurses is causing.
Thanks!
Very short and basically: It might use the TTY ioctl calls to get and set flags needed for the different modes. Then it could simply use read to read characters in a blocking or non-blocking manner.
Special keys (like the function keys for example) are read using multiple characters which are parsed.

How to read multiple lines in string until specified character in C [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
Need to read everything until say *** comes up:
Input:
Hey there
how are
you
***
Output:
Hey there
how are
you
Would have used scanf("%[^***]s) but can't read all lines at once.
Only having basic C knowledge
The way I would do this is read one line at a time (with a funcion such as fgets instead of scanf) and then see if the line that you last read is equal to ***. You can use use strcmp to do that but you can also do it by hand if you are not allowed to use strcmp for some reason.

How can i add blank space inside printf in c programming? [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 want to add two blank space inside c programming print statement. I have try but it always count one single space. How can i add another one ?? If i use \t then it count 4 space as set.
printf("Hello Dhaka!");
printf("Hello Dhaka!"); adds 2 spaces, since it contains 2 spaces.
The problem must be related to your output. Perhaps the console uses some strange font that is not fixed-width.

Resources