![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| comparing strings | agarwal | Shell Programming and Scripting | 3 | 04-16-2008 06:29 AM |
| Search for strings & copy to new file | amitrajvarma | Shell Programming and Scripting | 2 | 11-25-2007 11:51 PM |
| Sun's 'Project Copy Linux' not a Linux copy - Register | iBot | UNIX and Linux RSS News | 0 | 07-29-2007 06:31 AM |
| How to concatenate two strings or several strings into one string in B-shell? | fontana | Shell Programming and Scripting | 2 | 08-26-2005 12:58 PM |
| ksh - strings | itzcoolbuddy | Shell Programming and Scripting | 1 | 06-22-2005 11:26 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How can you copy strings?
Running into a bit of difficulty making duplicates of strings that enter the program via the command line. Evidently char p[] = q[]; doesn't work, and I can't do this:
[i] for( i=0 ; q[i] != EOF ; i++ ) p[i] = q; as the string I'm trying to duplicate comes from the command line, from argv[1], so I can't wedge the i in anywhere. Any ideas how I can get around this? |
|
||||
|
Nice, thanks... I fiddled with that and I seem to have a copy of the string. However I'm trying to append ".bat" onto the end of said string by means of strcat(), but it's giving me evil warnings and stackdumps when I try to compile / run it.
It allows me to strcat(argv[1], ".bat") but not, for some odd reason, strcat(*dup, ".bat"), where dup[] is a duplicate of argv[1]. |
|
|||||
|
Overwriting the arguments like you show in your first use of strcat is illegal too, even if the compiler doesn't catch and your cpu succeeds in running the resulting code.
Your second example of strcat is so bizarre that I'm not sure what to think. My best guess is that dup is an array of characters. If so, try strcat(dup, ".bat"); |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|