how to supress warning "gets() is deprecated"? [duplicate] - gcc

This question already has answers here:
Disable warning: the `gets' function is dangerous in GCC through header files?
(10 answers)
Closed 8 years ago.
everytime i try to input my string using gets() function, my compiler gives me warning like shown below. how to get rid of this. what am i doing wrong?
test.c:27:2: warning: ‘gets’ is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
gets(temp);
^

Use fgets instead:
fgets(temp, sizeof(temp), stdin);
gets is deprecated because it's dangerous, it may cause buffer overflow.

Related

Why do I get the error of "expr: syntax error" in a simple shell script [duplicate]

This question already has answers here:
macOS Mojave version 10.14.1 bash-3.2 expr: syntax error
(1 answer)
Bash: Find position of character in a string under OS X
(2 answers)
Closed 2 years ago.
My script is
#! /bin/bash
v1="hello"
v2="world1"
subIndex=`expr index "${v1}" "${v2}"`
echo $subIndex
and I got the error of "expr: syntax error"
It looks like you're using a version of expr which doesn't have an index operator.
As you can see in the POSIX standard man page there's no index in the table of operators. The only mention of index in that document says that the behaviour is undefined. We can assume that the standardisation process saw that only some implementations supported index and some or all of the participants did not want to add the additional functionality.
Some other implementations contain additional functionality above and beyond what is specified in the standard. You'll need to install one of these implementations or change your code. GNU expr is one implementation that does have index, length, etc..

Can't assign sass variable to css variable [duplicate]

This question already has answers here:
Sass Variable in CSS calc() function
(6 answers)
Closed 2 years ago.
This code doesn't work is Sass:
$color1:
.App {
--color1: $color1;
}
Why is this not valid syntax? What is the proper syntax?
This being invalid syntax is intended, the solution is to use:
$color1:
.App {
--color1: #{$color1};
}
The reason for this is discussed here: https://github.com/sass/libsass/issues/2621
In short, css variables could potentially be a string that starts with a $ character, and Sass did not want to block that syntax from working. Given that #{$someVar} is not valid css syntax, it is functional and more explicit to have it be this way.

In YAML, how do I make a comment over multiple lines [duplicate]

This question already has answers here:
How do you do block comments in YAML?
(11 answers)
Closed 6 years ago.
I know that you can make a single line comment in YAML by using the # tag, but I haven't been able to find something like /* in java that starts a comment & has to be finished off with a */. Does such an operator exist in YAML?
YAML does not support multiple line comments. If you want to use them. You can just try
# this
# is a multiple
# line comment

How to fix Preg_match () warning? [duplicate]

This question already has answers here:
Warning: preg_match() [function.preg-match]: Unknown modifier '/' [duplicate]
(2 answers)
Closed 8 years ago.
I am using preg_match function to my program like this
(preg_match('/^(f|ht)tps?\://', $this->sourceFilename))
But it shows a warning like this
Warning: preg_match() [function.preg-match]: Unknown modifier '/'
How can it modify? Please help me!!!
The last slash should be escaped
You need to escape the / inside the regexp:
preg_match('/^(f|ht)tps?:\//', $this->sourceFilename)
or use a different delimiter:
preg_match('#^(f|ht)tps?:/#', $this->sourceFilename)
BTW, you don't need to escape :.

After replacing eregi with preg_match I'm getting: preg_match() [function.preg-match]: Unknown modifier ',' [duplicate]

This question already has answers here:
Warning: preg_replace(): Unknown modifier
(3 answers)
Closed 3 years ago.
I'm using PHP Timeclock and I've had to mod several pages due to outdated code.
However, I'm stuck on this one:
preg_match Unknown modifier ',' in timeclock/admin/timeedit.php on line 274
preg_match ("/^([0-9]{1,2})-,/,.-,/,.$/i", $post_date, $date_regs))
This page was unchanged from the source. Any Ideas?
Try changing your Perl delimiters from / to something else.
got it with preg_match ("^([0-9]{1,2})[-,/,.]([0-9]{1,2})[-,/,.](([0-9]{2})|([0-9]{4}))$^"

Resources