Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modification #15

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

modification #15

wants to merge 6 commits into from

Conversation

sid050
Copy link

@sid050 sid050 commented Feb 9, 2020

No description provided.

Copy link
Contributor

@Phidelux Phidelux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,

the introduced changes are probably not necessary as they are handled in later assignments. However, I hope you find my comments on your changes helpful for yourself. If you are going to do further pull request in this or any other project, it would be very helpful if you would split them per section (in this case per assignment), squash your changes and add more meaningful commit messages. Finally it would be nice if you avoid spaces in filenames, as escaping them while compiling via command line sucks.

Thanks and best regards
Andreas

scanf("%f",&j);
char ch;
printf("enter the character \n"); //input a character
scanf("%s",&ch);
Copy link
Contributor

@Phidelux Phidelux Feb 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a potential security risk, as you are reading a string into a single char. You should consider using scanf_s() with %c instead:

scanf_s("%c", &c, 1);

EDIT: scanf_s is not part of C99 and is an optional extension of C11. So using it may reduce portability of your code, however most compilers implement it.

//date of creation: 05/02/20
int main()
{
int i;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing identation.

int main()
{
int i;
printf("enter a number \n"); //input an integer number
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for newline here:

printf("enter a number: ");

printf("%d is an integer \n",i);
printf("%f is a float \n",j);
printf("%s is a character \n",&ch);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty line not necessary and return statement missing.

printf("enter the last name \n"); //input last name
scanf("%s",&str2);
printf("hello %s %s",&str1,&str2);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty line not necessary and return statement missing.

{
char str1[10],str2[10];
printf("enter the first name \n"); //input the first name
scanf("%s",&str1);
Copy link
Contributor

@Phidelux Phidelux Feb 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you know the length of the string , you should consider using scanf_s() instead:

// Do not forget to account for the trailing null byte
scanf_s("%s", &str1, 9);

EDIT: scanf_s is not part of C99 and is an optional extension of C11. So using it may reduce portability of your code, however most compilers implement it.

scanf("%s",&str1);
printf("enter the last name \n"); //input last name
scanf("%s",&str2);
printf("hello %s %s",&str1,&str2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline in printf.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok sir i really appreciate your efforts to have a look at my report and thanks for the honest reviews

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants