Run a C program?

I want it to work so that when the user creates a c program, he or she can run it using the rn command that I have built. This command is supposed to communicate with the shell, which will execute the specified C code. It needs to be universal.

1 Like

um yeah you basically do make -s to compile all the c codes in the home directory and then you do chmod u+x path_to_file and then you do ./path_to_file

I got this error
Screen Shot 2023-03-04 at 2.02.53 PM
You may want to check my setup.c file which is located under “home.u/user”

1 Like

… bruh ok that’s kinda your problem if the code is not running properly but here you go, I did a little more digging and this works for everything:

cd directory_you_want
cc file_name.c -o output
chmod +x file_name.c
./output

so for your very specific case:

cd home.u/user
cc setup.c -o -c output
chmod +x setup.c
./output
1 Like

Still does not work. I think I shall just get it to work with Python files instead.

1 Like

What are the errors? It works for me

1 Like

Screen Shot 2023-03-04 at 2.27.12 PM

1 Like

yeah that’s a problem with your code, if you send me the code I will debug

I would have said you could simply find it in my folder in the project, but it is gone now. I am redoing it in Python.

1 Like

yes… you can redo it in python but it literally just needed to be debugged, I know it’s a big hurdle for new devs, but remember that code errors aren’t your enemy, just debug XD :smiley:

I have been. Also, I am not a new developer, but I have never tried familiarizing myself with terminal commands such as this.

1 Like
  1. bash commands :wink:
  2. really? how long have you been coding fellow long time dev :smiley:

For crying out loud. To me, bash is just “terminal”. Second, I have coded the same way many times, and even set up my own home server, but I only started using replit recently.

1 Like

very nice :smiley: I love meeting people who know more than me :smiley:

As I have already stated, I have removed the file, and do not have a record of it.

I see I believe restoring it is as simple as making a new file with the same name and using the history slider

Very well. I will try then

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#define MAX_USERNAME_LENGTH 100

int setup_main() {
    char username[MAX_USERNAME_LENGTH];
    char color[10];
    FILE *fp;

    printf("Welcome to OyoSoft Setup!\n");
    sleep(1);

    printf("Please enter a username: ");
    scanf("%s", username);

    fp = fopen("././home.u/sys/usrnme.txt", "w");
    if (fp == NULL) {
        printf("Error opening file.\n");
        exit(1);
    }
    fprintf(fp, "%s", username);
    fclose(fp);

    printf("Please choose a color theme (white, blue, green, red): ");
    scanf("%s", color);

    fp = fopen("././home.u/sys/color.txt", "w");
    if (fp == NULL) {
        printf("Error opening file.\n");
        exit(1);
    }
    fprintf(fp, "%s", color);
    fclose(fp);

    printf("Setup complete!\n");

    return 0;
}

That is for setup.c

Thanks I’ll get right to work :smiley: