Hi,
I'm getting a weird error with my C program. It receives parameters from a text file that is created by a VB wrapper program. One of the inputs is a "jobname". The code bombs when certain values are inputed for this jobname, but not others. This jobname is used to create a directory.
It crashes when the jobname has LLLLLLL_###LL, where L = letters, and # = digits, and _ = underscore. But, if there are only 2 digits & 2 letters or 1 letter after the 3 digits it works fine. Unfortunately, the user typically names the job name with this format (ex: "Bottle_400ml").
Has anyone seen anything like this before?
Thanks,
Sitko.
10 1721
Post the code that reads the jobname.
"weird error" is a little vague. Exactly what kind of error??
The error that pops up is:
"D:\Bottle_400mL
'-^' is not recognized as an internal or external command,
operable program or batch file.
The filename, directory name or volume label syntax is incorrect."
(note: the "^" symbol is an "up arrow" character.)
At first instead of "-^" it said "/Decline" is not recognized as an internal...
The code that I 'think' cause the error was this: -
if (strcmp(strType,"Decline")==0)
-
{
-
strcpy(sysCall,"mkdir ");
-
strcat(sysCall,gstrJobname);
-
system(sysCall);
-
}
-
if (strcmp(strType,"Decline")==0)
-
{
-
strcpy(sysCall, "mkdir ");
-
strcat(sysCall, gstrJobname);
-
strcat(sysCall, slash);
-
strcat(sysCall, strType);
-
system(sysCall);
-
}
-
I use conditional compilation statements, so that this code runs on both windows and unix.
'Slash" = whichever slash type is appropriate for whichever platform we're compiled on.
gstrJobname = the jobname the user typed in.
strType is either "Shake" or "Decline".
Thanks,
Sitko.
if (strcmp(strType,"Decline")==0)
{
strcpy(sysCall,"mkdir ");
strcat(sysCall,gstrJobname);
system(sysCall);
}
if (strcmp(strType,"Decline")==0)
{
strcpy(sysCall, "mkdir ");
strcat(sysCall, gstrJobname);
strcat(sysCall, slash);
strcat(sysCall, strType);
system(sysCall);
}
Tell me again how this code works. It looks like the strcmp is true in each case-and yioiu haver different contents.
Also, on the Windows side, your slash has to be \\.
I do have \\ on the windows side. LIke I said, this code works fine, EXCEPT for when the user inputs a job name with "_###LL" in it.
The code itself creates some text files, and a directory structure, which are fed into a downstream process. I can't go into too much detail as I've signed a NDA.
I don't think a code snipet is really helpful in this case, as it works fine, if they don't input that certain string value. So, it seems that C doesn't like that substring value for some reason.
Thanks,
Sitko.
Well, I was just wondering where the strTtype of "Shake" was. It's not in tyour code snippet.
There's nothing in C that prevents a jobname with # in it as you describe.
thanks...I didn't think it would...just wanted the opinion from you "experts"...what about if the string was ###_mL? Could the act of hitting "shift" to get the uppercase L case a problem?
"experts"...
You have to remember that X is an unknown qunatity and that a spurt is just a drip under pressure.
The shift key is not an issue. That just determines the value you receive fromthe keyboard.
Your problem is elsewhere. You might look at the VBA.
You have to remember that X is an unknown qunatity and that a spurt is just a drip under pressure.
The shift key is not an issue. That just determines the value you receive fromthe keyboard.
Your problem is elsewhere. You might look at the VBA.
Its definitely, in the C code where the error is happening. The VB front end, just builds the input.txt file for the C code, and I've checked and double checked, and everything is right going into the C code. Since then, I've seen a new "error" string with this code, another guy got "--<down arrow>" as being the offensive line.
At some point you wuill have to post the code that's failing.
Yeah, unfortunately, TPTB (the powers that be) have decided for the short term to just not use input that causes the problem, instead of investing time narrowing down the location of the offensive code. As the original error we got was "/Decline" is not a command, etc. I thought I had included the offending code in post #3 above.
The gstrJobName is read in like all the rest of the parameters, its code is this:
Its definition is:
My input file is based on one input parameter per line in a specified order. The VB file creates this input when the user clicks the 'write' button. The VB creates the file saves it in the folder and then calls the C program.
I have an "Assign Variables' function which loads all the global variables with values from the input file. -
if( (filePtr = fopen("Input.txt","r") )== NULL)
-
{
-
printf("ERROR: The input file can not be opened.");
-
exit(1);
-
}
-
-
fscanf(filePtr, "%s", Jobname);
-
fscanf(filePtr, "%s", Bottlename);
-
Here is where I move the Jobname into the gstrJobName: -
strncpy(tempStr2,Jobname,(strlen(Jobname)));
-
strcpy(gstrJobname,tempStr2);
-
Here is my code to build the job directory, along with some of my conditional compilation code: -
//find the directory from the strBottleFile,
-
//which is everything before the last slash.
-
#if _WIN32
-
{pch=strrchr(gstrBottleFile,'\\');}
-
#else
-
{ pch=strrchr(gstrBottleFile,'/');}
-
#endif
-
intLastSlash = (pch-gstrBottleFile+1);
-
strncpy (gstrWorkingDir,gstrBottleFile,intLastSlash);
-
-
//build the jobdir from working directory & "/" & jobname
-
strcpy(gstrJobDir,gstrWorkingDir);
-
strcat(gstrJobDir,gstrJobname);
-
I can't really post more of the code, than this. I know that makes it hard, but these snipets contain all of the code that references that global variable gstrJobName...
I hope that helps...
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bharath Dhurjati |
last post by:
Hello,
I am looking for documentation that specifies the following behavior
exhibited by java.
The following (assuming MyClass.class is accessible and has a main())
java MyClass *
yields...
|
by: Georgy Pruss |
last post by:
On Windows XP glob.glob doesn't work properly for files without extensions.
E.g. C:\Temp contains 4 files: 2 with extensions, 2 without.
C:\Temp>dir /b *
aaaaa.aaa
bbbbb.bbb
ccccc
ddddd
...
|
by: MatthewRoberts |
last post by:
Howdy All,
I have a Windows Service that often stops in its tracks with no
exception and no explanation on our QA system.
During testing on the development machine, it can handle any workload,...
|
by: Leo |
last post by:
Does someone know if there is a setting in the python Unix world to
make the command history behave as it does in the Windows intepreter?
Specifically, I like the fact that the command history...
|
by: David |
last post by:
Hello,
I have an application that has been running for years
and had little problem with it. We've been retesting the
latest code under Windows 2003 and found a surprise.
There is a certain...
|
by: R. Ian Lee |
last post by:
I'm using the System.Web.Mail.SmtpMail object (.NET 1.1)
to send email from an ASP.NET application. Everything
works fine when I run it from Windows 2000 Server, but
not from WinXP Pro. Is it...
|
by: Dan Tallent |
last post by:
A textbox has a attribute for ReadOnly. This seems like such a simple
concept. When a textbox is set to read only the user cannot change the
contents of the field.
I have been trying to find...
|
by: asit |
last post by:
what is the difference between portable C, posix C and windows C ???
|
by: shobhitguptait |
last post by:
How to Run C#.NET Windows App on N/W with centralized DB using SQL SERVER 2000
Hello All...i m really grate full to c such a website where developers try to help people like us who face problems...
|
by: khurramlone |
last post by:
I am trying to generate a client proxy from a WCF service library. I am using VS2005, .NET 3.0 on a Windows XP Pro workstation. The WCF service is hosted in a windows service. When I run the windows...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |