Usage of \b and \r in C

The characters will get send just like that to the underlying output device (in your case probably a terminal emulator). It is up to the terminal’s implementation then how those characters get actually displayed. For example, a bell (\a) could trigger a beep sound on some terminals, a flash of the screen on others, or … Read more

fgetc(stdin) in a loop is producing strange behaviour

Terminals tend to be line-buffered, meaning that stream contents are accessible on a line-by-line basis. So, when fgetc starts reading from STDIN, it’s reading a full line, which includes the newline character that ended that line. That’s the second character you’re reading. As for fflush, that’s for flushing output buffers, not input buffers. So, what … Read more

Segmentation fault- strcat

You don’t have enough space in fn. By strcat’ing on to it you overwrite the end of its stack allocation and into the stack .. hence the segmentation fault. You could try the following instead: You just have to be sure that the whole path and filename can fit into 255 characters. Alternatively you could … Read more

segmentation fault using scanf

You need to initialize your pointers. Alternatively, use stack-allocated arrays. For example, instead of char *name, do char name[20]. (Note that this will limit your input to 19 characters; use a larger buffer if necessary.) Right now, you are passing uninitialized pointers into scanf() which effectively means that scanf() is going to write to an … Read more

Carriage return in C?

From 5.2.2/2 (character display semantics) : \b (backspace) Moves the active position to the previous position on the current line. If the active position is at the initial position of a line, the behavior of the display device is unspecified. \n (new line) Moves the active position to the initial position of the next line. … Read more

Use of flag in c?

I am the beginners of programming so,i don’t know the use flag in c.since ,i have searched many question about flag in c but i don’t get it.i request you to answer my question to you developers thank you.

previous declaration of ‘function’ was here in C [duplicate]

http://www.kernel.org/doc/man-pages/online/pages/man3/getline.3.html getline already exists in stdio.h. That is why you are getting the error. Change the function name to something else like getline_my. Also, you are comparing a character with a string in line 16. It should beif(c == ‘\n’) NOT if(c == “\n”)

What is char ** in C? [duplicate]

Possible Duplicate:What is double star? I am fairly new to C, and have come across this statement I have a pretty good idea of what typedef does, but I have never seen char** before. I know that char* is a char array or similiar to a string. Im not sure if char** is a 2d … Read more