I want to clear the output of a C program produced with printf statements. I want to clear only one line, for example: [source] [terminal] [I hope] I will “DDDDDDDDDDDDDD” line in write other string. I just want the above A, B, C sentences to left. Only clear D sentences to change the other sentences, unconditionally output D sentences. How
Tag: c++
Why glibc’s fclose(NULL) cause segmentation fault instead of returning error?
According to man page fclose(3): RETURN VALUE Upon successful completion 0 is returned. Otherwise, EOF is returned and the global variable errno is set to indicate the error. In either case any further access (including another call to fclose()) to the stream results in undefined behavior. ERRORS EBADF The file descriptor underlying fp is not valid. The fclose() function may
gdb step not working as expected
I am debugging static multi-threaded x86-64 C++ application on Linux. I can set breakpoints on functions and stop on them and I can walk step by step over function body. But when I try to step into another function, gdb not stops at it’s beginning and it seems that it just continues execution. When I interrupt program execution, gdb goes
Is fopen() a thread safe function in Linux?
If I use fopen() call to open a same file in multi-thread, and write data to the file. Should I use a mutex to ensure the data won’t be disordered? Answer If two threads both open the same file with fopen(), they will each have independent file streams (FILE *) backed by independent file descriptors referring to the same file.
Get text from GTK entry
I’m trying to get what a user has inputed in a text field (entry) but when i run it i keep getting null from gtk_entry_get_text. Errors : Code : So how do i get the input from the user and not just null every time? Answer Pointer to pointer is needed: And in main:
Grouping child processes with setpgid()
I just don’t get the whole thing. My process tree: I want to make a process group (3, 4, 5), and send this group a signal from, say, 2. I tried it this way: Where should I place my setpgid() block? I tried placing it in 3, 0 and every other process, but setpgid()s return either “No such process” or
hex code implementation for spawning a shell
I am trying to implement the codes given in smashing the stack for fun and profit by Aleph to learn the basics of buffer overflow attacks. Machine architecture: Ubuntu 12.10 64 bit programs compiled using -m32 flag in gcc So far, I have managed to spawn a shell using the assembly instructions. The next step is to convert those instructions
I am really confused with this kind of compilation error( C ffmpeg Qt)
I downloaded the latest ffmpeg source code and successfully installed it on Ubuntu But I failed to compile a simple demo.(I did included proper headers) Here are the error messages ,just to name a few: Can you help me solve this problem? Contents Added: e.g this is my includes e.g AVFormatContext is declared in /usr/include/libavformat/avformat.h error message box shows Unknown
C — using chdir() function
I’m trying to use chdir() function but can’t work it out. I’m reading from user and find out if he is using “cd”. I always get an error. What am I doing wrong? Code: Answer If the line being entered is something like: then the directory starts at offset 3, not 2. In addition, fgets usually gives you a line
Building linux binaries for multiple platforms
Help me settle a score. I have a piece of software written in C++ that’s meant to run on as many linux distributions as possible and I need to figure out a strategy that’s effective. I’m trying to ship binaries in this case not source code (might be good to know). It’s already a commercial product and I have intellectual