ANSI colors in C and ncurses

I know I can do the attron and attroff with the color I choose to, however, I would like to know if it's possible to do it with the ANSI colour escape codes within ncurses: #include...

Substitute for getch(), gotoxy(), delay(), clrscr()

I have some old program source code that I wrote for Turbo C compiler.I made changes to them and want to recompile them in newer compilers for Linux and Windows.So please tell me what are the BEST...

Ncurses: Detecting if F1 key pressed and using signals

i am trying to learn ncurses library and i came up with code below: #include <ncurses.h> #include <stdlib.h> #include <signal.h> static void finish(int sig); int main(int argc, char** argv) { ...

Can we reassign the reference in C++?

I have read everywhere that a reference has to be initialized then and there and can't be re-initialized again. To test my understanding, I have written the following small program. It seems as if...

C++ underflow and overflow

Hi I am new in here so please let me know if anything is wrong and I will try to better the next time . I am trying to understand how underflow and overflow works in C++ .My understanding is if a...

Functional Programming Vs Declarative Programming Vs Imperative Programming

I have been too used to Imperative Programming which is the usual way of telling the computer to perform step by step the procedure to get the final result. On the other hand, declarative...

regex in C language using functions regcomp and regexec toggles between first and second match

I am using Dev-c++ IDE to compile my C (WIN32 API) programs. I am using regex lirary provided by http://gnuwin32.sourceforge.net/packages/regex.htm I am using this documentation for reference and...

Using backspace with ncurses

I have a simple ncurses program set up that reads characters one at a time with getch() and copies them into a buffer. The issue I am having is detecting a press of the backspace key. Here is the...

Python method for reading keypress?

I'm new to Python, and I just made a game and a menu in Python. Question is, that using (raw_)input() requires me to press enter after every keypress, I'd like to make it so that pressing...

User input for array index+index value in C

This is a question that I have found on this site but the responses were not directly related to what I believe my problem is. I am a little embarrassed because I'm still very much an amateur. I...

How do I print the percent sign(%) in C?

Why doesn't this program print the % sign? #include <stdio.h> main() { printf("%"); getch(); }

C Program that counts how many pass or fail grades and exits when a negative number is inputted

I'm a newbie to C Programming and we're still starting on the loops. For our exercise today, we were tasked to create a do-while program that counts how many pass and fail grades there are but the...

How to alphabetically sort strings?

I have been trying to use this c++ program to sort 5 names alphabetically: #include <iostream> #include <cstring> #include <conio.h> using namespace std; int main() { char names[5][100]; int...

modify large array and error in CUDA

I am programming in CUDA and problem in large array #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <conio.h> #include <stdlib.h> #define arraySize...

Heap corruption detected: after normal block(#62)

I code #include<stdio.h> #include<conio.h> void Nhap(int *x, int y) { for(int i=0; i<y; i++) { printf("x[%d] = ",i); scanf("%d",&x[i]); } } void Chen(int *a, int *b,...

How do I clean input buffer before using getch()?

So, I am using GetAsyncKeyState() to see when some key is pressed. But, after using it I need to use getch(). But it seems that getch() gets whatever GetAsyncKeyState() got before again. That is...

Returning string from C function

I haven't used C in over 3 years, I'm pretty rusty on a lot of things. I know this may seem stupid but I cannot return a string from a function at the moment. Please assume that: I cannot use...

Boundary fill algorithm in C not working (Computer Graphics - C Programming)

I'm trying to implement the simple boundary fill method (using 4 connected approach) for filling a rectangle. I did it as follows (code below), but the rectangle is not getting filled properly: it...

Haskell: Avoiding heap overflow in tree+zipper construction

I'm trying to implement a simple lexicon compression algorithm that uses Deterministic Finite Automaton as a data structure (actually it is Deterministic Acyclic Finite State Automaton, see...

Ncurses: comparing input and a chosen word from the textfile

I'd like to make the "Falling words" typing game (you type the word before it lands on the bottom of console) but I'm stuck because I don't know if my declaration might even work. For now this...

Filling rectangles using floodfill c++

I'm trying to make a grid of rectangles to look like a checkerboard and am having some trouble using BGI graphics. I have gotten my code to produce a series of rectangles, but every time I try to...

How can you print multiple variables inside a string using printf?

I want to find the maximum value of two numbers, and print it. I want to print all three numbers. I am using the following code. #include<stdio.h> #include<conio.h> main() { //clrscr(); ...

Read list of numbers in txt file and store to array C

I have a problem with reading the numbers. After I run the program everything is fine but there are no numbers in the array. I have tried different ways of writing the numbers in the file with no...

How does the compiler know the prototype of printf( ) in this code?

In the following code, #include<conio.h> clrscr(); gotoxy(10, 20); ch= getch(a); we can see that the library functions have been called without defining their prototype, the three library...

How to create a folder in C

How can I create a new folder for an email manager, I have this code but It doesn't work. void create_folder() { int check; char * dirname; clrscr(); printf("Enter a directory path...

Wierd problem with fstream. Cannot store objects with member variables having a certain value

When I try to store an object with any element having a value of 13 or 26 or 7 and then try to read this file, it simply gives garbage values. This doesn't happen with other values like 1, 64, 78...

How can I resolve the "cout was not declared in this scope" error?

just a simple program but can anyone point out why this error is occuring, (i am using dev C++ version 5.11) #include <stdio.h> #include <conio.h> class animal { public : void sound(); ...

C Program (Prime Number in a given range)

I have started learning C language. I wrote this program to find all prime numbers between the given range but I am unable to get the expected output. Can anyone tell me what's wrong with this...

How to read and display file data using int86 function with REGS struct for 8086 in C-Language

I have a text file with some content I have to move the cursor in from relative to the BOF and display its content on the screen using int 21h/42h. here is the code I am working on. I am using...

can we write only return instead of return 0,1

#include<stdio.h> #include<conio.h> int SumEvennatural(int); int main() { int n; printf("Enter N:"); scanf("%d", &n); printf("sum %d", SumEvennatural(n)); getch(); return...