Program in C: Linux Development Basics
This issue can be taken by multiple CodeHeat participants. Anyone can grab this issue at any time. Once you are done, submit the outcome via the form below.
OBJECTIVE
Learn about basic development techniques on the Linux platform by learning how to develop a simple C language program with vim, how to build it with GCC and run it.
REQUIREMENTS
- Follow the openEuler mirror repository on GitHub indicating your participation
- Learn basic tools and commands that could be used while software development on Linux platform
- Follow this instruction
- Complete all the steps
- Take a screenshot of the output at the final step (a calculation of cos and sin value)
EXPECTED OUTCOME
- Learn how to use basic tools and command lines
- Successfully build and run a simple program on Linux platform
HOW TO SUBMIT YOUR WORK
- Submit your screenshot here
QUESTIONS
- If you have any questions, please comment on this issue directly, or reach out to us at https://gitter.im/fossasia/fossasia
- If you identify any problem while working on this issue, take up a related task to file a bug report
Hi, when working on this issue, I got a few warnings and errors when compiling the 4 C files at the end of Step 3, as shown in the picture below. I fixed them on my end and can share my code if needed.
Hi, when working on this issue, I got a few warnings and errors when compiling the 4 C files at the end of Step 3, as shown in the picture below. I fixed them on my end and can share my code if needed.
I think this issue is fixed now. This is the code on my end :).
Even so, I don't think the function cos_value should be header guarded with SIN_VALUE_H
Yeah, one of the changes I made was replacing all the SIN_VALUE_H in cos_value.h with COS_VALUE_H, and the code worked as a result.
@hpdang Do we need to only submit the form or need to make the PR?
@ankur0904 only submit the form, thanks!
@hpdang Thanks!
@hpdang
The code provided in the zip file has the following files-
- cos_value.c
- cos_value.h
- hello.c
- main.c
- sin_value.c
- sin_value.h
And the main.c code looks like that
#include <stdio.h>
#include "sin_value.h"
#include "cos_value.h"
#define pi 3.14159
char name[255];
float angle;
int main(void)
{
printf("\n\nPlease input your name: ");
scanf("%s", &name);
printf("\nPlease enter the degree angle (ex> 90): ");
scanf("%f", &angle);
printf("\nInput angle: %5.2f", angle);
hello(name); //// <---------------- ////
sin_value(angle);
cos_value(angle);
return 0;
}
But in the main.c, we are calling the hello function with the name argument, but we have not included the name function like sin_value, cos_value in main.c file so when we compile these files we get the warning like this
main.c:17:5: warning: implicit declaration of function ‘hello’; did you mean ‘ftello’? [-Wimplicit-function-declaration]
17 | hello(name);
| ^~~~~
| ftello
Solution to this problem:
Create a new file hello.h with the following code
#ifndef HELLO_H
#define HELLO_H
void hello(char* name);
#endif
And in main.c
#include <stdio.h>
#include "sin_value.h"
#include "cos_value.h"
#include "hello.h" // <---------- Add the code //
#define pi 3.14159
...
After that, the code is compiled and consistent with the remaining files sin_value.c, cos_value.c.
If the issue is valid I am happy to submit a PR
@ankur0904 yes, please feel free to submit a PR at the same time you can take up another task to file a report.
@hpdang I have noticed that the C program files are zipped under the tar file here. So I am confused how to make changes in the file. Meanwhile, I will look at another task
Thanks
@hpdang I have noticed that the C program files are zipped under the
tarfile here. So I am confused how to make changes in the file. Meanwhile, I will look at another taskThanks
Opening a issue there may be a good idea.
Perhaps the bug in awsome_codes.tar.gz is an exercise for you to do Identify an issue and file a bug report on openEuler?
Done this issue succesfully, no issues ran in while i was doing it in AWS Redhat based Linux VM
hi, I am unable to run the tar files on macbook, can anyone please help . Thanks!
Hi, when working on this issue, I got a few warnings and errors when compiling the 4 C files at the end of Step 3, as shown in the picture below. I fixed them on my end and can share my code if needed.
![]()
hi, i got the following issues while working, can you please help curl: (6) Could not resolve host: s Warning: Binary output can mess up your terminal. Use "--output -" to tell Warning: curl to output it to your terminal anyway, or consider "--output Warning: <FILE>" to save to a file.
hey @hpdang !, can i work on issue. I am eager to learn linux
