Search Results

Search: Posts Made By: GQiang
Forum: Programming 08-07-2011
2,110
Posted By yazu
Use "strcmp" for strings (char *). See man 3...
Use "strcmp" for strings (char *). See man 3 strcmp.
Forum: Programming 08-06-2011
2,110
Posted By pludi
In C, variables can be accessed in 2 ways:...
In C, variables can be accessed in 2 ways: directly, or as pointers, where a pointer is, basically, the address where the memory reserved for that variable starts. Now here's the funny thing: there...
Forum: Programming 08-06-2011
2,110
Posted By yazu
In function arguments It is a pointer. It is...
In function arguments It is a pointer.

It is the maximum number of chars that you can get in the buffer (1 is needed for the last '\0'). So if you input more you can't overflow the buffer.
...
3,335
Posted By agama
His code is checking for any character(s)...
His code is checking for any character(s) followed by a character that is not a number, followed by any character(s). I think you've missed seeing the bang (!) which implies not 0-9:


(...
3,335
Posted By agama
Are you using bash or Kshell? This should...
Are you using bash or Kshell?

This should work regardless:

while [ "$author" = "" -a "$title" = ""];

You want to loop when both strings are empty (and) rather than one or the other. I'm...
3,335
Posted By agama
( [!0-9]|"" ) will just match a single...
( [!0-9]|"" )

will just match a single character. If the user enters "a" it will print the error, but if the user enters "aa" it will not. So, by adding the two wildcard characters, you allow it...
1,136
Posted By aigles
Try: sed...
Try:
sed "s/$title:$author:$price:$qtyAvailable:$qtySold/$Ntitle:$author:$price:$qtyAvailable:$qtySold/"

Jean-Pierre.
2,041
Posted By itkamaraj
c1=`grep -w $title BookDB.txt |grep -w $author|wc...
c1=`grep -w $title BookDB.txt |grep -w $author|wc -l` #cannot work when got space


Give the sample contents of BookDB.txt

and you can use grep -c for counting ( instead of wc -l)
2,041
Posted By Nitrodist
$title expands to whatever the value of it was....
$title expands to whatever the value of it was. So, how would you grep a file for a string with spaces in it? With quotes of course -- in this case, use double quotes because single quotes makes...
Showing results 1 to 9 of 9

 
All times are GMT -4. The time now is 09:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy