How to use crypt(3) in windows? - c

How can I invoke crypt(3) from a c program on a windows platform? I can't find a header file to include. I have MinGW with gcc and msys installed.
Edit: as an alternative, I would also accept a way to call this function (or an equivalent) from Visual Studio.

Have you seen this? http://sourceforge.net/projects/mingw/files/MSYS/crypt/
I suppose you may be missing it, or just don't realize you have it, but it seems like the answer, and I found it by typing "crypt mingw" into Google.

Related

Including basics library of C (unistd.h) on window

I've been programming at my school on a Mac for one month. We did C programming on an UNIX shell.
Now i'm back at home and I use my own PC that is on window 10. I have tried to make a similar set up, but i don't know much about all that. I installed git and bash, this made it like a UNIX shell. Also I have installed the gcc compiler.
So, now that i'm making a basic program, it should be working but when I make the include <unistd.h>, the shell can't find it.
I know my question is probably silly but I really couldn't find how to solve the problem. I downloaded the unistd.h file.
I also found this http://processors.wiki.ti.com/index.php/Compiler/diagnostic_messages/5
It explain that i should be putting the .h folder in some kind of defined path, but I don't know how to do that.
Does anyone know how I can fix this?
If you installed gcc as part of mingw or something similar, it should have included a unistd.h. Just having the gcc compiler is not likely to get you very far.
You probably want to start over and install something different than you did (mingw or cygwin or just set up a vm as suggested) that provides a more complete environment.

How to use fork() in Visual Studio 2015? (Windows 7 Professional)

I searched around and all I could find was that I needed Cygwin. I installed it but I can't seem to find unistd.h anywhere in C:\cygwin64\usr\include. Of course, I added that path to the "Include Directories" in my Project in VS2015.
What I want to do is be able to use fork() and execv() (or maybe execl(), execlp(), execvp() etc...) in C. I know the easy solution is just "Go do it in Linux" but VS2015 makes it easier to code correctly.
What I think I should do is, I should install something else from Cygwin which would include the headers I need, I just don't know how and where to find them, so I'm asking your help.
unistd.h is a unix file. You can't use it on Windows
fork(),execv(),...etc all are linux OS commands which won't work in windows.. so either u should try in a linux system or use a virtual window to use linux system.

conio.h is missing from Windows

I usually use VS but trying cygwin for the first time. I am using windows 7 but on compiling hello world program using gcc, it says "fatal error: conio.h: no such file or directory".
I am using Windows 7 and it seems conio.h is missing from my system. Can someone please tell me how to resolve this issue.
Thanks!!
In Cygwin there doesn't exist any such header file called conio.h! Also, you don't need it either because it automatically holds screen for you without using getch() and for clrscr() you do have system("clear") in Cygwin!
conio not being part of the standard library, you cannot expect it to be available cross-platform, or even between compilers on the same platform.
Being, non-standard, the name conio has been used by both Borland and Microsoft for libraries with differing APIs - Microsoft's is much smaller. So for that reason you might avoid it for portability.
It is not a matter of conio not being on Windows, Cygwin is a POSIX API layer and tool-chain for building and running POSIX code on Windows. The libraries provided with it are independent of those provided with Visual Studio.
There are a number of solutions including:
Use an alternative console I/O library, such as ncurses.
Use a conio source code implementation for Linux such as this (which uses ncurses and implements Borland's API).
The second solution is perhaps useful if you have a lot of legacy code using conio, but is overkill if you just want to prevent a console windows from closing. For that you could just use getchar() in any case and accept that you will have to press enter rather than any key.
If you are using Cygwin just to be able to use GCC on Windows, you might be better off using MinGW/GCC instead. This uses Microsoft's C runtime rather than GNU, and the Win32 API rather than POSIX.

How can I compile C files into an executable (.exe) file?

I am unsure about compiling C files into executables by using Cygwin under Windows 7.
Can anyone please tell me how to do this?
I've read some tutorials but still don't get it. I understand that I need a Makefile, but what shall I write into it to have an executable file after the compilation process?
For the beginning I would say it is enough to Install MinGW. If you have installed it you find in the bin folder a gcc.exe which is the Compiler. Either set the PATH Variable to the bin folder or go directly to this folder.
In terminal use:
gcc your_C_file.c
The output will be an exe.
There are several ways to compile c-files. Makefiles are just one possibility. But as you proposed it... Here are two tutorials for Makefiles:
http://makepp.sourceforge.net/1.19/makepp_tutorial.html
http://mrbook.org/tutorials/make/ (Content from 2012 accessable via waybackmachine)
But note, that you will also need a compiler (installed under cygwin).
Another possibility is to use Dev-C++, a IDE (Integrated Developement Environment) for C++. Once installed you can create a project and add your source code, and just compile the project. It also contains a c++ compiler (also supports C), which is named mingw. The makefile needed is automatically generated. So that's simpler for beginners.
You can download Dev-Cpp here: http://www.bloodshed.net/devcpp.html
Note: As you spoke about cygwin I assume you use Windows. Dev++ works only under windows, and you wont need cygwin.
Q: How can i compile c-files into an executable (.exe) file?
A: Get and use a C compiler.
GCC/Cygwin is one possibility. MS Visual Studio is another: you can download the free "MSVS Express" here: http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express.
How you interact with the compiler is another question.
You can certainly use a command line.
You can use a command line with or without "Make": you can let "Makefiles" do the "heavy lifting" for you, you can use .bat files, or you can type everything by hand.
Using a graphical IDE is another possibility. "Eclipse" and "MS Visual Studio" are two popular alternatives for Windows.
Even easier solution is A86 Assembler. Its old school but works perfectly, in the right hands ;)

Where can I find the string.c file itself (to read it)?

I'm interested in reviewing some of the functions included in the string library for c, but I can't find the source code (literally, i.e. functions and all) online and I have no idea where to find it.
Thanks.
EDIT:
the link provided by pmg shows those functions divided into c files, so it's about what I needed. Thanks.
Take a look at redhat glibc. It appears to be somewhat current.
You'll find it in the source code of the gcc compiler.
http://www.gnu.org/software/gcc/
Usually included with the compiler that you install so this may vary. Also depends on the operating system your running. If you're using windows, I recommend you run a Windows search for strings.c and if you're running linux then you can use the find command.
Disregard the file I linked to prior to this edit. I should have verified the code before sending it. It didn't apply to your question. Sorry
Maybe you're looking for GNU C string.h?
You can check the source in any standard libc implementation http://www.gnu.org/software/libc/

Resources