Aia 1,977 Nearly a Posting Maven

Your code is not portable. You are using functions that do not work in Windows 7

Aia 1,977 Nearly a Posting Maven

Why google for something they don't believe is a problem? Just because someone says don't is not enough of a reason.

And that's not my problem. I don't post for the ignorant that doesn't care of being ignorant, but rather for that one coming behind, reading much later, wanting to know and not be mislead.

And if that's why I'm here, why post at all if I'm just gonna have to clean up after you? I don't even clean up after my kids, and you're old enough to know better :icon_twisted:

You misunderstood me. That's why you here, because any time it strikes your fancy, that's what you like to do. But it is OK when you don't feel like.

WaltP commented: Makes sense.... +11
Aia 1,977 Nearly a Posting Maven

In other words, gets() and fflush().

It's good to give an explanation, not just tell people something and they just have to believe you. None of us have credibility to new posters.

That's why you are here.
On the other hand I only give what I want to give. A simple search in this forum or even Googling for the terms should provide enough information for the mind that wants to be instructed.

Aia 1,977 Nearly a Posting Maven

hello there, you are apparently getting closer to the success of your program.

Would it be alright to suggest? I bet you can also use fflush(stdin); before your first gets() statement. That will help you in your future encounter towards string inputs.

Good Luck!

You are the one that will need a lot of luck if you think it is acceptable to make use of fflush(stdin) and gets().
fflush() is undefined if you give it stdin as an argument.
gets() is not an option even for throw away code.
It would be better if you do not touch the keyboard at that point.

Aia 1,977 Nearly a Posting Maven

gets() and scanf("%s", ...) are functionally identical. See this to understand why you never use either.

scanf() does accept width doesn't it? It can be made safe to use to read a string by just adding width to the string specifier, but not gets()

Aia 1,977 Nearly a Posting Maven

Please use gets() instead of scanf() if you expect spaces in the user input. scanf() does not handle spaces the way you want it to work.

gets() is not an option, because there's no way of controlling how much data can be inputed. There's no way of using it safely.
scanf() is an option to read input string, but a mischiefing one.
A better option to read string input would be fgets().

Aia 1,977 Nearly a Posting Maven

Can you please compile my program and let me know if it is working? I'm still having trouble with it.

Thanks!

That has been done for you already. Dave Sinkula told you, here. Perhaps, it will be better if you practice some more basic steps?

Aia 1,977 Nearly a Posting Maven

The program compiles and this is the the output I get:

?Invalid number of arguments
Press any key to continue . . .

Can somebody please take a look at this program and give me some ideas?

You must not be entering the right amount of parameters when running the program at the command line.
It requires three: the name of the program and the two strings representing numbers.

Aia 1,977 Nearly a Posting Maven

The problem is in how awk accepts an external variable, in this case $dat.

awk -v Var_date=$dat '{if(( $5 > 200 ) && ( $6 == Var_date ))
Aia 1,977 Nearly a Posting Maven
for songs in $(cat "~Desktop/1/list.txt"); do cp $songs NewSongs/; done

The while loop is more appropriate for it. The for loop will need the $IFS (Internal Field Separator) modified.

while read songs
do
    cp "$songs" NewSongs/
done < ~Desktop/1/list.txt
Aia 1,977 Nearly a Posting Maven

BTW
Drop the & in scanf(), it is either scanf("%s", name) or scanf("%s", &name[0]) , but not scanf("%s", &name)

Aia 1,977 Nearly a Posting Maven

yes I have understood. Now that I have removed the while statement, I am still encountering the same problem (printing only 0s). Could it be that as an output I am getting only the first byte of the frame, or am I displaying the array incorrectly? Thanks a lot.

Cleaning the code and fool-proof it a bit.

#include <stdio.h>
 /* Unless you're doing something else this is the only header file needed */

#define SIZE 1000

int main(void)
{
	int Array[SIZE]={0};
	int j;
	
	FILE *cfPtr;
	
	if ((cfPtr = fopen("Error Pattern 2.dat","r") ) == NULL)
	{
		printf("File cannot be opened\n");
                /*
                 * Need to handle the error and stop here if you want
                 * to put the fclose() at the end of the code
                 */
                 return 0;
	}/* end if */ /* <--the if doesn't end here, there's a possible else */
	else
	{
		for (j = 0; j < SIZE; j++) {
                        /*
                         * Need to check that fscanf was successful
                         * Need to stop if it did not succee.
                         * Need to stop the for loop count if failed
                         */
			if ( fscanf (cfPtr,"%d", &Array[j]) != 1 ) {
                               /* failed to read more numbers */
                               fprintf(stderr, "Ending...\n");
                              /* stop counter  */
                               i = 100; /* get out of the loop */
                        } else {
                               /* Hopefully most of the time there's something read */
			      printf ("%d\n",Array[j]); /* adding a new line after read to ensurer proper display */
		}
	}
			
	fclose(cfPtr);
        return 0;
}
Aia 1,977 Nearly a Posting Maven

Hi all,

I have a simple question as it appears.
But am unable to get the solution.

Question is -how do I get the access time of a file in unix. please advise on the command.

Thanks

stat might give you what you want.

Aia 1,977 Nearly a Posting Maven
scanf("%f", &length);

length is an int, you are passing a float. Same with scanf("%f", &breadth); Either you change the type in the declaration of length and breadth, or change the f to d in the calling of scanf().

Aia 1,977 Nearly a Posting Maven

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] } }'

# if( NF > 7 ) checks that there are more than seven fields
# split($7, a, ":") splits field seven into parts according to delimiter ":" and stores it into array a
# print a[1] displays part 1 which must be the hour

Aia 1,977 Nearly a Posting Maven

[...]
I just/only want the modification date.?[...]
i cant use 'ls' cmd, this displays all fields
[...]

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 helpful dealing with strings. Considerate this:

ls -l | awk '{ print $8 " was modified on " $6 }'
Aia 1,977 Nearly a Posting Maven

Hi,
Please help in this regard.

Can the modification time of a file be updated to any date of our choice?

Please advise.

Thanks in advance!

Look into the command touch

Aia 1,977 Nearly a Posting Maven

Hi Aia,
Thanks for ur advice.

I initially tried using if/endif, but it didnt work out, I got the same error.
I also used != for condition checking, but that also didnt help.

PLease help.

Thanks in advance..

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
Aia 1,977 Nearly a Posting Maven

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.

Aia 1,977 Nearly a Posting Maven

hi Scott,
Am getting this error for the code

Missing ]

Please help

Post your code the way you wrote it to execute. Make sure there's a space between [ and ]

Aia 1,977 Nearly a Posting Maven

I am trying to delete any line of text that contains "$npname" and the word "in." The script works if $npname is only one word, but if it is more than one work I get "error: unterminated address regex" How can I fix this?

sed '/'$npname'.*in/d' parts.txt > parts.tmp

It makes a difference the quotation scheme.

sed "/$npname.*in/d" parts.txt > parts.tmp
Aia 1,977 Nearly a Posting Maven
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 be correct, line is bound to have more characters read into, that the pattern, (unless fgets() by coincidence reads only the pattern).
Maybe the function strstr() would be more helpful.

You open the file in main() and read from it, then you open the same file in the function and read from it, you do not close it in the function, then close it in main. I'll say there's something odd, don't you think?

Aia 1,977 Nearly a Posting Maven

The controlling expression of a switch shall have integer type.
An array of chars will not do.

Aia 1,977 Nearly a Posting Maven

Maybe I worded it incorrectly. I know how to manipulate arrays etc but I don't know how to parse a file properly.

Do you know how to open a file and read from it?

Aia 1,977 Nearly a Posting Maven

I am trying to read integers from a file and store them into an array but I have no idea how to do it. [...]

One step at a time.
Start learning how to assign values to arrays.
Learn how to read a single or group of characters from a file.
After that it is just a matter of parsing what's read and manipulating the data.

Aia 1,977 Nearly a Posting Maven

I know my problem is within the SWITCH CASE!!

Plenty of thing are erroneous in your snippet, however I would like to point out the cause of your affliction for now.

printf(" A - Addition\n S - Subtraction\n M - Multiplication\n D - Division\n Q - Modular\n");

/* use scanf to receive the letter for the operation*/
scanf("%d", &operation2);

If you expect a letter, how come you are asking scanf() to parse an integer?
A why a letter, when you define ADDITION, SUBTRACTION, etc... as integer constants?

Aia 1,977 Nearly a Posting Maven

Close but not quite right Aia.

This will leave a leading space and a trailing space before the line feed.

You can fix yours OSiRiSsk. Just check for the EOL and reset the flags.

Funny, I thought that was part of the requirement.

Aia 1,977 Nearly a Posting Maven

well but i will read multiple lines, so how to make this code right ?

Perhaps another approach?

#include <stdio.h>
#include <ctype.h>

void clean_spaces(void);
int main(void)
{
    clean_spaces();
    return 0;
}

/*
 * clean_spaces will leave only the first space found and it ignores extra
 * instances
 */
void clean_spaces(void)
{
    int c;

    do {
        c = getchar(); /* reads a char from stdin */
        /*
         * checks if the char read is a space. Displays the firts of it.
         * will disregard any consecutive space. Newlines should be excluded.
         */
        if (isspace(c) && c != '\n') {
            /* if expression works as a flag that space is in */
            putchar(c);
            /*
             * we know that previously we read a space, is the next one
             * another?
             */
            while (isspace((c = getchar()))); /* ; */
        }
        /* last char read is not discarded */
        putchar(c);

    } while (c != EOF);
}
Aia 1,977 Nearly a Posting Maven

Here's an assignment. Search why

gets(s[i]);

is a no no.

What is it that you are sorting the names by?

Aia 1,977 Nearly a Posting Maven

Files Infected:
C:\WINDOWS\system32\SKYNETlog.dat (Trojan.Agent) -> No action taken.

SKYNET is used as part of rootkit technology which will be hard to clean unless you understand what's going on.
Maybe this thread will do just that

A solution I find more secure is to boot with UBCD and open a terminal. Then type:

CD C:\Windows\System32
DEL /S SKYNET*.*

And reboot.
That will disable the rootkit enough for Malwarebytes to finish the job afterward.

Aia 1,977 Nearly a Posting Maven

you posted wrong solution. Can not use temp variable.

priyairani00> "program to swap two no. using third variable"

Aia 1,977 Nearly a Posting Maven
tmp = a;
a = b;
b = tmp;
Aia 1,977 Nearly a Posting Maven

EvilOrange> <--Line 27 - proving the scanf("%s", &tmpfilename) is working
Dealing with the format %s in scanf() you must pass the argument as plain tmpfilename or as &tmpfilename[0] , but not as &tmpfilename EvilOrange> >Cannot open (null) <--Line 30
Are you sure is line 30 and not line 46? fprintf(stderr,"Cannot open %s\n",argv[2]);

Aia 1,977 Nearly a Posting Maven

there is only 2 var missing and thats:

char a;
FILE *out;

argv[2] is NULL which is why this bit of code comes into play

On the phone
Nick: Doctor, can you cure my cough? It is a horrible cough, I cannot sleep at night.
Dr. Hell: Sorry, Nick, I cannot prescribe the proper medication without seeing you first, make an appointment for tomorrow.
Nick: OK.
Next day at Dr Hell's consult.
Dr Hell: Who are you?
Nick's buddy: I am Nick's best friend. He told me that you needed to see him first, in order for you to prescribe medicine for his cough. So he sent me with his best photograph taken last year at the summer's party.


EvilOrange> there is only 2 var missing and thats:
That's not enough.

Dr Hell guesses that it has to do with...

scanf("%s", &tmpfilename);
Salem commented: My diagnosis - this code is dead, it has ceased to be +36
Aia 1,977 Nearly a Posting Maven
printf("\nyour is grade A",Total);

Take a look at that one. Figure what are you missing.

When you post code you need to wrapped around code tags to present it in a proper format. See here.

Aia 1,977 Nearly a Posting Maven

PetuniaRose> Is there any chance that if and when you have the time, you could tell me how

Copy and paste.

Aia 1,977 Nearly a Posting Maven

I see folks replying to threads with quotes that have the name of the original poster included - they have the form

nameOfPoster> quote [...]

I use that form in conversations when I need to bring focus to a particular portion of the quote. And I use the name from origin so people don't have to follow the linear sequence of the conversation and still catch up quickly.

Aia 1,977 Nearly a Posting Maven

no1zson> can somebody look at my IF loop (the first one for selcting 1-3) and see where I am going wrong?

I am sure we can guess what you are trying to do, but don't you think it would be more effective if you tell us what is supposed to do and what's doing which is not the expected result?

no1zson> if storenum >=1 || if storenum <=3]

if (storenum >= 1 && storenum <= 3) {
    /* do something */
}
no1zson commented: thanks for the tip +3
Aia 1,977 Nearly a Posting Maven

yellowSnow> If this is the case, then perhaps you should try using the strtok() function.
strtok() is a poor designed function, which make this recommendation a poor choice.

Aia 1,977 Nearly a Posting Maven

EvilOrange> string[j][0] = string; <-- HERE IS THE PROBLEM

string[j][0] is a space to hold a character
string, on the other hand, is an array of characters. For sure there's going to be a problem if you try to push a bunch of character where only one can live.

Aia 1,977 Nearly a Posting Maven

nonadoes> Only need to extract the number after "_C", "_V", "_S" & "_M"
Search for character _ and when you find it skip one more and that's the number you want.

Aia 1,977 Nearly a Posting Maven

[...] although I don't understand why did you use IF condition ...?

sscanf() returns EOF if it fails or the number of items that has been successfully read. By using an if statement a minimum of checking has been accommodated. It is imperative to check the return of functions. How does the saying goes?: Assume makes an ass out of u and me.

Aia 1,977 Nearly a Posting Maven
int main()
{
char *p = "hello all ";
printf(p);
}

I thought the above code should ve showed a compile time error. but it din , any reason how it worked?

You are mistaken. int printf ( const char * format, ... ); is the prototype. You passed it the proper argument.

Aia 1,977 Nearly a Posting Maven

bugtussellmom> I'm guessing there is some way to destroy them so the data can't be read?
A cheap and easy way of producing satisfactory results, destroying hard drives, is to drill a couple holes with a twisted bit, through the body.
No need to go any other extends to prevent data mining.

Aia 1,977 Nearly a Posting Maven

Why do i not need an '&' ive always thought you needed that? and regardless of the file pointer name it stil gives me a partly garabge output :S

file_name is a pointer already to the first character of the array.
You must omit the & or do it as &file_name[0]

The garbage output probably happens because the string is not terminated with a '\0' at some point.

Aia 1,977 Nearly a Posting Maven

For your Dell you need to use the "Reinstallation CD". That would partition your hard drive the way it came first from Dell, and it will install the Operating System it came with the Computer.

Floppy is a thing from the past. Installation are done today from DVD. CD's are still use as well.

The sequence for a generic installation is essentially this:
Attach the new hard drive to the computer.
Hit the key that the black screen tells you that is the set up.
That gets you into the Basic Input Output System, BIOS, for short.
There, you need to make sure what the boot up preference is, and change it to boot from CD/DVD drive, if necessary.
Save configuration and exit.
Insert Bootable media into any of the drives.
New hard drive will need to be partition before operating system is installed. Some times, the prepared installation will do it for you automatically, like the Resinstallation CD, other times as with a generic XP installation, the set up will ask you to choose and what to do.
After that, is a click and click process.
Kind of simplified but these are the steps.

The safer way is to remove any other hard drives. Windows will recognize the removed HDD once you placed back.

Aia 1,977 Nearly a Posting Maven

In order to undo an unintended wrong I did to the OP poster I summit this link explaining, and my public apologies to Salem if the email wasn't enough.

Aia 1,977 Nearly a Posting Maven

blackrobe> Can you please give me an example on how to use the "sed" command in this case??...

I can do better than that, I will give you a link to an easy to understand tutorial that will initiate you to sed.

Aia 1,977 Nearly a Posting Maven

>Senseless and unprovoked bashing? - jlm699

I wouldn't mind if you, could elaborate on it, since I don't get your intention with the bad rep. Heck! I don't even know if you are asking me if bashing should be senseless and unprovoked, or if you are not sure if my post was senseless and unprovoked bashing.

Which begs the question, why would provoked bashing and with sense be any better?
Anyway, I digress. Next time that you are so prompt to quickly leave your puny "yellow" mark, have the "cojones" of addressing your disapproval in a real post where others can comment on it.

By the way, my comment was not directed to anyone in particular but rather a reflection of the thought that quantity is irrelevant here.

Salem commented: Works for me +0
Aia 1,977 Nearly a Posting Maven

Actually, compared to US political standards the amounts in question are pitifully small.

That should make the rest of the world happy! Right?
Look! At least, we are not like those suckers in USA; trying to hold the #1 position at everything they do.

[Edit:] Or should I had said... holding the #1 position at any cost?

jlm699 commented: Senseless and unprovoked bashing? -1
Salem commented: Senseless and unprovoked bashing! FTW +0