Forum: Shell Scripting 22 Hours Ago |
| Replies: 6 Views: 441 Drop the use of grep in this case, since it is not necessary.
sed 's/OUT.*$/IN/g' < original_file > result_file |
Forum: Shell Scripting 3 Days Ago |
| Replies: 14 Views: 379 If you want to continue using awk as the workhorse, then:
ls -l f3.sh | awk '{ if( NF > 7 ) { split($7, a, ":"); print a[1] } }' |
Forum: C 4 Days Ago |
| Replies: 4 Views: 189 Read the comments I added to your source code.
Of course if you were looking to assign the values of the structure poly p at declaration time, then it would have been:
struct poly p = { 45, { 1,... |
Forum: C 4 Days Ago |
| Replies: 9 Views: 244 If you would take a little time to understand the information I gave you via links, in the second post, you probably would have not need to ask that question. |
Forum: C 4 Days Ago |
| Replies: 9 Views: 244 Or up and down. It doesn't matter. It is undefined behavior.
If a plane doesn't have a pilot, it doesn't matter if people speculate about the capacity of fuel tanks to make the trip, or the... |
Forum: C 4 Days Ago |
| Replies: 9 Views: 244 Click here (http://www.daniweb.com/forums/post1048411.html#post1048411) and here (http://www.daniweb.com/forums/post1049104.html#post1049104). |
Forum: Shell Scripting 4 Days Ago |
| Replies: 14 Views: 379 As you have been shown you can pipe the ls command to another program that further parses the output, in this case awk.
awk can do a lot of things, but even in its simplest form it can be very... |
Forum: C 4 Days Ago |
| Replies: 6 Views: 290 Expressions has direct effects and side effects.
This expression, x = y; has a direct effect of copying the computed value of y assigning it to the location x.
x = a[i]; has a direct effect as... |
Forum: Shell Scripting 5 Days Ago |
| Replies: 14 Views: 379 Look into the command touch |
Forum: C 5 Days Ago |
| Replies: 4 Views: 189 I knew there was more to it than what you stated previously.
What you wanted to know is if a void function can be use as the stop control for a loop. And the answer is ... no. There's nothing for... |
Forum: C 5 Days Ago |
| Replies: 4 Views: 189 Yes, why do you ask? There must be something else you want to know. |
Forum: C 5 Days Ago |
| Replies: 2 Views: 160 Instead of out = fopen (out, "w");
it must be out = fopen ( filename, "w" ); where filename is a string with the path to the file you want to write.
Remember, when you use the "w" if the file... |
Forum: C 5 Days Ago |
| Replies: 6 Views: 290 Those two expressions invoke undefined behavior. Anything can be the result.
It is best if you write int main(), and return inside of main to comply with the standard. |
Forum: Shell Scripting 5 Days Ago |
| Replies: 11 Views: 521 if ( ${cnt} -ge "1" ) That reads if cnt is greater or equal to 1 therefore != would have not worked.
if ($cnt >= 1) then
# whatever you want to mail
endif |
Forum: C 5 Days Ago |
| Replies: 3 Views: 212 There's not such a mechanism of translating C to Java, except for the most rudimentary and simple statements. Since both languages are different, all that it can be done is to understand what the... |
Forum: C 5 Days Ago |
| Replies: 4 Views: 178 Variable str is created when the function leer() is used. It is [1]destroyed when the function leer() is finished. You are returning a pointer to that memory that might or might not contain the... |
Forum: Shell Scripting 6 Days Ago |
| Replies: 11 Views: 521 csh doesn't use if/fi but rather if/endif. Look at posted script and you'll see you have an if/fi.
BTW csh doesn't have the same conditional operators than bash so -ge doesn't work. |
Forum: C 8 Days Ago |
| Replies: 5 Views: 313 The rules of this forum clearly explain that we do not give away code to posters that do not show proof of effort. Where's the code? Where is your effort in the matter? |
Forum: C 9 Days Ago |
| Replies: 6 Views: 258 Nope. More like:
struct amicable *record;
/* record must point to some memory before using it */
record = &a_struct_amicable_block_of_memory; /* can be done with malloc */ |
Forum: C 9 Days Ago |
| Replies: 10 Views: 294 :) segmentation faults occur when you are trying to access memory that you are not suppose to. e.g.
int *x; /* declares a pointer to int, the variable x is holding a random value which will be used... |
Forum: Shell Scripting 9 Days Ago |
| Replies: 11 Views: 521 Post your code the way you wrote it to execute. Make sure there's a space between [ and ] |
Forum: C 9 Days Ago |
| Replies: 4 Views: 188 When you are the original poster you'd see at the bottom, after the last post, the mark as solved title, in blue. Click on it. |
Forum: Shell Scripting 9 Days Ago |
| Replies: 4 Views: 265 Find any difference between both and then match it. e.g. with HOOK by itself in a line we can match the beginning and end of the line. Thus:
grep '^HOOK$' file_name
Once you have down the... |
Forum: Geeks' Lounge 10 Days Ago |
| Replies: 20 Views: 1,114 You are worthy of more than one. There! |
Forum: Shell Scripting 10 Days Ago |
| Replies: 5 Views: 329 It makes a difference the quotation scheme.
sed "/$npname.*in/d" parts.txt > parts.tmp |
Forum: Shell Scripting 10 Days Ago |
| Replies: 3 Views: 281 What's the trouble?
In its simplest form, create another executable script with three lines of text, where each line is the absolute path to those three scripts. |
Forum: C 10 Days Ago |
| Replies: 10 Views: 294 char *c; is a pointer, again, it doesn't point to any proper memory allocated to it.
while(fgets(c, 600, fin)!=NULL)
Guess what you are trying to do there? Yeap! Trying to write to poor char *c... |
Forum: C 10 Days Ago |
| Replies: 10 Views: 294 For some, memory management in C, is a curse, nevertheless it is one of the strength of the language.
After allocating memory for it, remove any & in front of those pointers to string like... |
Forum: C 10 Days Ago |
| Replies: 10 Views: 294 struct REPLY *reply; is a pointer, anything you try to write to it it will produce a segmentation fault, since there's no memory allocated for it. |
Forum: C 10 Days Ago |
| Replies: 8 Views: 259 shakunni >Anyone know why this is the case?
A function must be called from another function block which could be the main function or one with a lineage to any main function.
Meaning that main()... |
Forum: C 12 Days Ago |
| Replies: 2 Views: 181 To save the transaction you are almost there.
int bal = 0; /* initialize balance to zero */
instead of bal = 0 + credit; replace for bal = bal + credit; or bal += credit; which is a shortcut. |
Forum: C 13 Days Ago |
| Replies: 2 Views: 174 |
Forum: C 17 Days Ago |
| Replies: 4 Views: 162 It was intended to be a hint, rather that a question to answer. |
Forum: C 17 Days Ago |
| Replies: 10 Views: 447 if( line == pattern)
That's a no-no, since line and pattern are strings and you can't compare arrays in that way.
Take a look at the string function strcmp() for that.
However, even if that would... |
Forum: C 17 Days Ago |
| Replies: 4 Views: 162 if (data_size == SIZE_32 ) {
* ( ((int32_t*)(new_node->data)) + index) = (int32_t) index*2 ;
* ( ((int32_t*)(new_node-> data)) + index) = (int32_t) index*3;
}
else {
*... |
Forum: C 17 Days Ago |
| Replies: 6 Views: 295 The controlling expression of a switch shall have integer type.
An array of chars will not do. |
Forum: C 19 Days Ago |
| Replies: 4 Views: 212 It doesn't matter, if she follows your advise she will get a square.
Then you'll learn nothing.
Some clue:
One loop inside another one as previously said.
Outer loop is the number of rows.... |
Forum: C 19 Days Ago |
| Replies: 2 Views: 208 First, you must understand what constitutes a string in C. It is a sequence of chars terminated with a '\0'.
So if I have this:
char fullname[] = "Jiminy Cricket";
and I want to split it into name... |
Forum: C 21 Days Ago |
| Replies: 11 Views: 457 In the C89 standard, an array must be set with a constant. Which would not allowed what you just did.
int cantidad_frases = 0;
printf("Cuantas frases quieres escribir?: ");
scanf("%d",... |
Forum: C 22 Days Ago |
| Replies: 2 Views: 230 fgets( student[count_s].name, sizeof (student[count_s].name), stdin ); |