-
Can someone please run this in XP
Could someone please run this code in XP and let me know if it works. I am on Windows 7 and have looked at this code for 2 months now and not able to find a solution to save my life. If you see what is wrong with it though please let me know my output keeps getting "file not given"
Code:
#include <windows.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <list>
using namespace std;
bool isPalindrome(const std::string& s)
{
std::string sReverse = s;
std::reverse(sReverse.begin(), sReverse.end());
return s == sReverse; // return true if the reverse is the same as non-reverse
}
//MAIN FUNCTION
int main(int argc, char *argv[]){
HANDLE readFile, writeFile;
HANDLE readFileMap, writeFileMap;
PVOID pvreadFile, pvwriteFile;
DWORD readFileSize;
string word = "";
list<string> words;
//VERIFYING ARGUMENTS
if(argc>1)
{
readFile = CreateFile(argv[1], GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
//IF STATEMENT TO CHECK IF THE READ FILE IS NOT VALID
if(readFile == INVALID_HANDLE_VALUE)
{
//DISPLAY ERROR MESSAGE
std::cout << "Read file could not be opened." << std::endl;
return(FALSE);
}
readFileMap = CreateFileMapping(readFile, NULL, PAGE_READONLY, 0, 0, NULL);
//IF STATEMENT TO SEE IF THE READFILEMAP IS NULL
if(readFileMap == NULL)
{
//DISPLAY ERROR MESSAGE
std::cout << "Read file map could not be opened." << std::endl;
CloseHandle(readFile);
return(FALSE);
}
pvreadFile = MapViewOfFile(readFileMap, FILE_MAP_READ, 0, 0, 0);
//IF STATEMENT TO DETERMINE IF PVREADFILE IS NULL
if(pvreadFile == NULL)
{
//DISPLAY ERROR MESSAGE
std::cout << "Could not map view of read file." << std::endl;
CloseHandle(readFileMap);
CloseHandle(readFile);
return(FALSE);
}
//DETERMINE SIZE LIMIT OF INPUT FILE
readFileSize = GetFileSize(readFile, NULL);
//writeFile = CreateFile(argv[2], GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
writeFile = CreateFile(argv[2], GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
//IF STATEMENT TO DETERMINE IF WRITE FILE IS VALID OR NOT
if(writeFile == INVALID_HANDLE_VALUE)
{
//DISPLAY ERROR MESSSAGE IF FILE CAN'T BE OPENED
std::cout << "Write file could not be opened." << std::endl;
//std::cout << "argv[1] = " << argv[1] << " argv[2] = " << argv[2] << std::endl;
UnmapViewOfFile(pvreadFile);
CloseHandle(readFileMap);
CloseHandle(readFile);
return(FALSE);
}
writeFileMap = CreateFileMapping(writeFile, NULL, PAGE_READWRITE, 0, readFileSize, NULL);
//IF STATEMENT TO DETERMINE IF WRITE FILE MAP IS NULL
if(writeFileMap == NULL)
{
//DISPLAY ERROR MESSAGE THAT THE WRITE FILE CANNOT BE MAPPED
std::cout << "Write File could not be mapped." << std::endl;
CloseHandle(writeFile);
UnmapViewOfFile(pvreadFile);
CloseHandle(readFileMap);
CloseHandle(readFile);
return(FALSE);
}
pvwriteFile = MapViewOfFile(writeFileMap, FILE_MAP_WRITE, 0,0,0);
//IF STATEMENT IF THE PVWRITEFILE IS NULL
if(pvwriteFile == NULL)
{
//DISPLAY ERROR MESSAGE THAT I COULD NOT OPEN MAP VIEW OF WRITE FILE
std::cout << "Could not open map view of write file." << std::endl;
}
//POINTERS NEED TO BE CREATED
PSTR readptr = (PSTR) pvreadFile;
PSTR writeptr = (PSTR) pvwriteFile;
{
bool ret = isPalindrome( "eve redivider" );
}
//CLEANUP THE FILE
UnmapViewOfFile(pvwriteFile);
UnmapViewOfFile(pvreadFile);
CloseHandle(writeFileMap);
CloseHandle(readFileMap);
CloseHandle(writeFile);
CloseHandle(readFile);
}
//ELSE STATEMENT IF CANNOT FIND FILE
else
//DISPLAY ERROR MESSAGE THAT NO FILE IS GIVEN
cout << "No file given" << endl << endl;
//RETURN A VALUE
return 0;
}
-
Re: Can someone please run this in XP
Quote:
Originally Posted by
jimJohnson123
If you see what is wrong with it though please let me know my output keeps getting "file not given"
It took you two months to see that this is executed?
Code:
if(argc>1)
{
// stuff I don't care about
}
//ELSE STATEMENT IF CANNOT FIND FILE
else
//DISPLAY ERROR MESSAGE THAT NO FILE IS GIVEN
cout << "No file given" << endl << endl;
So why does it fall into the else block? (and please fix your formatting).
Regards,
Paul McKenzie
-
Re: Can someone please run this in XP
I can see that this is what is executing I just cant see what is wrong with it. I believe my issue is in the CreateFile but not fore sure
-
Re: Can someone please run this in XP
Quote:
Originally Posted by
jimJohnson123
I can see that this is what is executing I just cant see what is wrong with it. I believe my issue is in the CreateFile but not fore sure
???
Are you looking at the code? It is clearly obvious that argc is <= 1 causing that line to be printed. I even simplified it for you in my previous post.
Now why is argc <= 1? It has nothing to do with CreateFile() not working. It has everything to do with your command-line arguments not being correct.
Regards,
Paul McKenzie
-
Re: Can someone please run this in XP
Would anyone else be able to look at this. I mean no disrespect Paul but I am really not a good at the programming aspect for my degree(which is not what I am even going into) and dont understand exactly what I am supposed to do still but I do appreciate you trying and I will rate you top in the post ratings.
-
Re: Can someone please run this in XP
Quote:
Originally Posted by
jimJohnson123
..
I ... dont understand exactly what I am supposed to do still ...
Well, What else could I add to the Paul's answer? :confused:
If you still don't understand the very trivial logic with if...else block then, please, set a break point at the beginning of your main(), start debugging (F5), and debug your code step-by-step (F10) to see the variable values and where and why you will "go" with your code.
PS: and don't expect someone will run/test your code because the reason of your problem is very obvious. :cool:
-
Re: Can someone please run this in XP
Quote:
Originally Posted by
jimJohnson123
Would anyone else be able to look at this.
I told you what was wrong.
I don't understand -- did you write this code? If you did, then how can you not know what if/else is supposed to do? No one else can break it down for you any simpler than that.
Code:
if ( this statement is true )
{
// do this stuff
}
else // statement is not true
{
// do this instead
}
So look at your code -- replace "this statement is true" with "argc>1". Now, the only way that line could have printed was if argc>1 is not true. So by using logic, argc must have been <= 1 for that line to be printed, since argc>1 was false.
Regards,
Paul McKenzie
-
Re: Can someone please run this in XP
is this what you are talking about...
Code:
#include <windows.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <list>
using namespace std;
bool isPalindrome(const std::string& s)
{
std::string sReverse = s;
std::reverse(sReverse.begin(), sReverse.end());
return s == sReverse; // return true if the reverse is the same as non-reverse
}
//MAIN FUNCTION
int main(int argc, char *argv[]){
HANDLE readFile, writeFile;
HANDLE readFileMap, writeFileMap;
PVOID pvreadFile, pvwriteFile;
DWORD readFileSize;
string word = "";
list<string> words;
//VERIFYING ARGUMENTS
if(argc>1)
{
readFile = CreateFile(argv[1], GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
//IF STATEMENT TO CHECK IF THE READ FILE IS NOT VALID
if(readFile == INVALID_HANDLE_VALUE)
{
//DISPLAY ERROR MESSAGE
std::cout << "Read file could not be opened." << std::endl;
return(FALSE);
}
readFileMap = CreateFileMapping(readFile, NULL, PAGE_READONLY, 0, 0, NULL);
//IF STATEMENT TO SEE IF THE READFILEMAP IS NULL
if(readFileMap == NULL)
{
//DISPLAY ERROR MESSAGE
std::cout << "Read file map could not be opened." << std::endl;
CloseHandle(readFile);
return(FALSE);
}
pvreadFile = MapViewOfFile(readFileMap, FILE_MAP_READ, 0, 0, 0);
//IF STATEMENT TO DETERMINE IF PVREADFILE IS NULL
if(pvreadFile == NULL)
{
//DISPLAY ERROR MESSAGE
std::cout << "Could not map view of read file." << std::endl;
CloseHandle(readFileMap);
CloseHandle(readFile);
return(FALSE);
}
//DETERMINE SIZE LIMIT OF INPUT FILE
readFileSize = GetFileSize(readFile, NULL);
//writeFile = CreateFile(argv[2], GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
writeFile = CreateFile(argv[2], GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
//IF STATEMENT TO DETERMINE IF WRITE FILE IS VALID OR NOT
if(writeFile == INVALID_HANDLE_VALUE)
{
//DISPLAY ERROR MESSSAGE IF FILE CAN'T BE OPENED
std::cout << "Write file could not be opened." << std::endl;
//std::cout << "argv[1] = " << argv[1] << " argv[2] = " << argv[2] << std::endl;
UnmapViewOfFile(pvreadFile);
CloseHandle(readFileMap);
CloseHandle(readFile);
return(FALSE);
}
writeFileMap = CreateFileMapping(writeFile, NULL, PAGE_READWRITE, 0, readFileSize, NULL);
//IF STATEMENT TO DETERMINE IF WRITE FILE MAP IS NULL
if(writeFileMap == NULL)
{
//DISPLAY ERROR MESSAGE THAT THE WRITE FILE CANNOT BE MAPPED
std::cout << "Write File could not be mapped." << std::endl;
CloseHandle(writeFile);
UnmapViewOfFile(pvreadFile);
CloseHandle(readFileMap);
CloseHandle(readFile);
return(FALSE);
}
pvwriteFile = MapViewOfFile(writeFileMap, FILE_MAP_WRITE, 0,0,0);
//IF STATEMENT IF THE PVWRITEFILE IS NULL
if(pvwriteFile == NULL)
{
//DISPLAY ERROR MESSAGE THAT I COULD NOT OPEN MAP VIEW OF WRITE FILE
std::cout << "Could not open map view of write file." << std::endl;
}
//POINTERS NEED TO BE CREATED
PSTR readptr = (PSTR) pvreadFile;
PSTR writeptr = (PSTR) pvwriteFile;
{
bool ret = isPalindrome( "eve redivider" );
}
//CLEANUP THE FILE
UnmapViewOfFile(pvwriteFile);
UnmapViewOfFile(pvreadFile);
CloseHandle(writeFileMap);
CloseHandle(readFileMap);
CloseHandle(writeFile);
CloseHandle(readFile);
}
if(argc>1)
{
// stuff I don't care about
}
//ELSE STATEMENT IF CANNOT FIND FILE
else
//DISPLAY ERROR MESSAGE THAT NO FILE IS Given
cout << "No file given" << endl << endl;
//RETURN A VALUE
return 0;
}
-
Re: Can someone please run this in XP
Quote:
Originally Posted by
jimJohnson123
is this what you are talking about...
That "stuff I don't care about" is what I wrote, because I really don't care about all of that code you posted. Again:
Code:
//VERIFYING ARGUMENTS
if(argc>1)
{
// this is all of your code, and I don't care what it does,
// so please don't post it as it has absolutelty nothing to do with your problem!
}
else
// cout an error saying you can't open the file.
That is a synopsis of the code you posted. So how does it get into the "else" portion? It doesn't matter what that code is that you posted does inside the if() block -- it has absolutely nothing to do with the issue, so it need not be posted over and over again. The only way it can get to that line is if argc <=1. So where does argc come from?
Code:
int main(int argc, char *argv[])
So why is argc <= 1? That is what I'm asking you. How did argc turn out to be <= 1 instead of > 1? Where does argc get its value? Something gave argc a value, so what is it? (I know what it is -- I'm asking if you know what it is that gives argc its value).
Regards,
Paul McKenzie
-
Re: Can someone please run this in XP
That is a mixed salad of C++ carrots and Win32 apis potato chips. Anyway it works on my XP after some minor corrections
-
Re: Can someone please run this in XP
aight thanks still tryin to figure it out but appreciate the help
-
Re: Can someone please run this in XP
If the error message is "file not given", then you are not supplying
the file at the command prompt when you execute the program.
What are you typing to execute the code ?
Why bother with argc/argv ? Get the code working with a hard-wired
filename.
-
Re: Can someone please run this in XP
I really am just going in with start without debugging in visual studio
-
Re: Can someone please run this in XP
You must start debugging! :cool:
-
Re: Can someone please run this in XP
this is what it shows...
'Palindrome.exe': Loaded 'C:\Users\Bryan\Documents\CSI 345\Palindrome\Debug\Palindrome.exe', Symbols loaded.
'Palindrome.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'Palindrome.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'Palindrome.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'Palindrome.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
'Palindrome.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
The program '[6548] Palindrome.exe: Native' has exited with code 0 (0x0).
-
Re: Can someone please run this in XP
-
Re: Can someone please run this in XP
By doing so this is the line I am getting the error in but cannot figure out why...
readFile = CreateFile(argv[1], GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
I believe it has something to do with argv[1]
-
Re: Can someone please run this in XP
When you run from the command line, the argument that you give
the executable will be argv[1]. What are you entering ?
argv[1] = filename
As I mentioned in my previous post, remove tghe argc/argv coding
and hardwire a filename. Does your code work ?
-
Re: Can someone please run this in XP
I am not sure what I even am supposed to run from the command prompt
-
Re: Can someone please run this in XP
jimJohnson123, open up your command prompt and try actually using the program the way it was designed to be used. You type:
name_of_program.exe name_of_file_to_process
When you execute the programs from the command line, and supply the name of your file, then argc will be > 1.
The reason you've been failing is because you are trying to run the thing from the MSVC IDE!
-
Re: Can someone please run this in XP
OK I guess I am just not doing command prompt right as this is what I did...
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Bryan> cd C:\Users\Bryan\Documents\CSI 345\Palindrome\Palindrome
C:\Users\Bryan\Documents\CSI 345\Palindrome\Palindrome>palindrome.exe
'palindrome.exe' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\Bryan\Documents\CSI 345\Palindrome\Palindrome>
My program is located here...
C:\Users\Bryan\Documents\CSI 345\Palindrome\Palindrome
The following files are located here...
debug(folder), Palindrome (C++ source), Input(text document), Palindrome (VC project), palindrome.vcxproj (VC++ Project Filter File), Palindrome.vcxproj(Visual Studio Project User Options File)
I just need someone to show me how to run this through command prompt and please only positive feedback I do not want anyone responding with rude comments(not saying anyone has just want to be upfront) My reasoning is this is probably extremely simple for most of u guys thats all
-
Re: Can someone please run this in XP
You're right, it's very simple. Judging from post #15,
Quote:
'Palindrome.exe': Loaded 'C:\Users\Bryan\Documents\CSI 345\Palindrome\Debug\Palindrome.exe', Symbols loaded.
your executable is in "'C:\Users\Bryan\Documents\CSI 345\Palindrome\Debug\"
So, open a command prompt:
C:
CD \Users\Bryan\Documents\CSI 345\Palindrome\Debug\
Palindrome.exe <NAMEOFTHEFILE>
-
Re: Can someone please run this in XP
I did that with input.txt and get the error read file map could not be opened so it does not it past the first section
-
Re: Can someone please run this in XP
I think I read on how to fix this....
If I wanted to how would I cast argv[1] and argv[2] to a LPCTSTR data type?
-
Re: Can someone please run this in XP
Quote:
Originally Posted by jimJohnson123
If I wanted to how would I cast argv[1] and argv[2] to a LPCTSTR data type?
just like the how your code below does
Code:
readFile = CreateFile(argv[1], GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
CreateFile
HANDLE WINAPI CreateFile( __in LPCTSTR lpFileName, ..... );
LPCSTR stands for long pointer const string... basically. The same as const char* which char* is being implicitly casted to.
-
Re: Can someone please run this in XP
does that even seem like what needs to be done to fix this or am i reading something that is not the problem
-
Re: Can someone please run this in XP
Quote:
Originally Posted by jimJohnson123
I did that with input.txt and get the error read file map could not be opened so it does not it past the first section
If your output didn't read "No file given", it will try to open the file. You will have to use GetLastError() after the last call that failed to return the error code. Look up the number at http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx to find why it didn't work
-
Re: Can someone please run this in XP
I did read
Code:
if(argc>1)
{
// stuff I don't care about
}
which seems to be misplaces and should be deleted, but go ahead and run this modified version
Code:
#include <windows.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <list>
using namespace std;
bool isPalindrome(const std::string& s)
{
std::string sReverse = s;
std::reverse(sReverse.begin(), sReverse.end());
return s == sReverse; // return true if the reverse is the same as non-reverse
}
//MAIN FUNCTION
int main(int argc, char *argv[]){
HANDLE readFile, writeFile;
HANDLE readFileMap, writeFileMap;
PVOID pvreadFile, pvwriteFile;
DWORD readFileSize;
string word = "";
list<string> words;
//VERIFYING ARGUMENTS
if(argc == 3 )
{
cout << "opening for read: " << argv[1] << endl;
readFile = CreateFile(argv[1], GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
//IF STATEMENT TO CHECK IF THE READ FILE IS NOT VALID
if(readFile == INVALID_HANDLE_VALUE)
{
//DISPLAY ERROR MESSAGE
cout << "Read file could not be opened. Error code: " << GetLastError() << endl;
return(FALSE);
}
readFileMap = CreateFileMapping(readFile, NULL, PAGE_READONLY, 0, 0, NULL);
//IF STATEMENT TO SEE IF THE READFILEMAP IS NULL
if(readFileMap == NULL)
{
//DISPLAY ERROR MESSAGE
cout << "Read file map could not be opened. Error code: " << GetLastError() << endl;
CloseHandle(readFile);
return(FALSE);
}
pvreadFile = MapViewOfFile(readFileMap, FILE_MAP_READ, 0, 0, 0);
//IF STATEMENT TO DETERMINE IF PVREADFILE IS NULL
if(pvreadFile == NULL)
{
//DISPLAY ERROR MESSAGE
cout << "Could not map view of read file. Error code: " << GetLastError() << endl;
CloseHandle(readFileMap);
CloseHandle(readFile);
return(FALSE);
}
//DETERMINE SIZE LIMIT OF INPUT FILE
readFileSize = GetFileSize(readFile, NULL);
cout << "Opening for write: " << argv[2] << endl;
//writeFile = CreateFile(argv[2], GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
writeFile = CreateFile(argv[2], GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
//IF STATEMENT TO DETERMINE IF WRITE FILE IS VALID OR NOT
if(writeFile == INVALID_HANDLE_VALUE)
{
//DISPLAY ERROR MESSSAGE IF FILE CAN'T BE OPENED
cout << "Write file could not be opened. Error code: " << GetLastError() << endl;
//cout << "argv[1] = " << argv[1] << " argv[2] = " << argv[2] << endl;
UnmapViewOfFile(pvreadFile);
CloseHandle(readFileMap);
CloseHandle(readFile);
return(FALSE);
}
writeFileMap = CreateFileMapping(writeFile, NULL, PAGE_READWRITE, 0, readFileSize, NULL);
//IF STATEMENT TO DETERMINE IF WRITE FILE MAP IS NULL
if(writeFileMap == NULL)
{
//DISPLAY ERROR MESSAGE THAT THE WRITE FILE CANNOT BE MAPPED
cout << "Write File could not be mapped. Error code: " << GetLastError() << endl;
CloseHandle(writeFile);
UnmapViewOfFile(pvreadFile);
CloseHandle(readFileMap);
CloseHandle(readFile);
return(FALSE);
}
pvwriteFile = MapViewOfFile(writeFileMap, FILE_MAP_WRITE, 0,0,0);
//IF STATEMENT IF THE PVWRITEFILE IS NULL
if(pvwriteFile == NULL)
{
//DISPLAY ERROR MESSAGE THAT I COULD NOT OPEN MAP VIEW OF WRITE FILE
cout << "Could not open map view of write file. Error code: " << GetLastError() << endl;
}
//CLEANUP THE FILE
UnmapViewOfFile(pvwriteFile);
UnmapViewOfFile(pvreadFile);
CloseHandle(writeFileMap);
CloseHandle(readFileMap);
CloseHandle(writeFile);
CloseHandle(readFile);
}
//ELSE STATEMENT IF CANNOT FIND FILE
else
{
//DISPLAY ERROR MESSAGE THAT NO FILE IS Given
switch( argc )
{
case 0:
cout << "No arguments given" << endl;
break;
case 1:
cout << "No read file or write file given" << endl;
break;
case 2:
cout << "No write file given" << endl;
break;
default:
cout << "Way too many arguments given." << endl;
}
}
cout << "Arg 0 = file to read" << endl;
cout << "Arg 1 = file to write to" << endl;
//RETURN A VALUE
return 0;
}
-
Re: Can someone please run this in XP
Quote:
Originally Posted by
jimJohnson123
does that even seem like what needs to be done to fix this or am i reading something that is not the problem
You still haven't proven you understand the very simple basics.
Where does argc get its value? If you don't understand or can't answer that question, then there is no way you are going to understand the program that you supposedly wrote.
Regards,
Paul McKenzie
-
Re: Can someone please run this in XP
Quote:
Originally Posted by
Joeman
which seems to be misplaces and should be deleted, but go ahead and run this modified version
If the OP doesn't understand a simple if/else, or know where argc gets its values and what it means, then the only thing left is to give the answer away and have it copied, and this board has a policy of not giving answers away.
Regards,
Paul McKenzie
-
Re: Can someone please run this in XP
Hopefully he will be back and has tried more :)
-
Re: Can someone please run this in XP
Paul McKenzie,
Please do not respond to any more of my posts including this one. I am really not needing to hear your comments anymore. I tried the code but I keep getting the same issue with the same errors...
'Palindrome.exe': Loaded 'C:\Users\Bryan\Documents\CSI 345\Palindrome\Debug\Palindrome.exe', Symbols loaded.
'Palindrome.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'Palindrome.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'Palindrome.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'Palindrome.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
'Palindrome.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
The program '[1240] Palindrome.exe: Native' has exited with code 0 (0x0).
These errors keep going to the same place which is if (argc>1) and my newest try which is at if (argc ==3) I also went to goggle to make sure generate debug info is saved to yes and it was
-
Re: Can someone please run this in XP
And I did not mean that post as negative to anyone else but Ill never use C++ again and just trying to get through this last program before thursday which is my last deaddline
-
Re: Can someone please run this in XP
How are you executing the program from the command prompt ? If
you are using argc==3 , you need to execute with something like:
Palindrome.exe input_file_name output_file_name
As I mentioned in my first post, why are you using argc and argv ?
Why not just hardwite the names of the files ?
-
Re: Can someone please run this in XP
Try my code and report the error any error. Also read about microsoft visual studio and setting up command arguments http://stackoverflow.com/questions/2...-visual-studio
or do what Philip suggest since it is easier to start with.
Quote:
Originally Posted by jimJohnson123
but I keep getting the same issue with the same errors...
'Palindrome.exe': Loaded 'C:\Users\Bryan\Documents\CSI 345\Palindrome\Debug\Palindrome.exe', Symbols loaded.
'Palindrome.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'Palindrome.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'Palindrome.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'Palindrome.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
'Palindrome.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
The program '[1240] Palindrome.exe: Native' has exited with code 0 (0x0).
Theses errors are of no concern to your problem
-
Re: Can someone please run this in XP
Quote:
Originally Posted by
jimJohnson123
Paul McKenzie,
Please do not respond to any more of my posts including this one. I am really not needing to hear your comments anymore. I tried the code but I keep getting the same issue with the same errors...
It is just because you think you are "not needing to hear your comments anymore". It is verz bad but for you only! :thumbd:
Quote:
Originally Posted by
jimJohnson123
... Ill never use C++ again and just trying to get through this last program before thursday which is my last deaddline
I would suggest you to use neither any type of programming nor any work concerning logic and mathematics. :cool:
-
Re: Can someone please run this in XP
Quote:
Originally Posted by
jimJohnson123
Paul McKenzie,
Please do not respond to any more of my posts including this one. I am really not needing to hear your comments anymore.
Sorry, CodeGuru doesn't work like that.
If you answered the questions I asked you, maybe you would solved the problem you're having. The questions I asked you are relevant to this entire discussion. You have an issue, and the issue is that you did not understand why an "else" block was executed, and I explained it to you very clearly. The reason why was that a variable, namely argc, was set to a number. Then I politely asked you where argc gets its value, but you couldn't answer.
The only conclusion that anyone can make from this is that you don't know what you've programmed, and you're relying on basically copying what Joeman and others are giving you and hoping it works.
Regards,
Paul McKenzie
-
Re: Can someone please run this in XP
Quote:
Originally Posted by
VictorN
I would suggest you to use neither any type of programming nor any work concerning logic and mathematics. :cool:
Programming just isn't made for everyone, yet everyone who takes up programming thinks they can tackle the work.
When it comes to logical thinking and thinking in discrete steps to reach a final goal, some persons have brains that are just not wired for this type of thinking, regardless of how smart they are in other fields.
Regards,
Paul McKenzie
-
Re: Can someone please run this in XP
the reason i use argc and argv is because it is required
-
Re: Can someone please run this in XP
Quote:
Originally Posted by
jimJohnson123
the reason i use argc and argv is because it is required
But to use them properly you must know what they are!
-
Re: Can someone please run this in XP
Quote:
Originally Posted by
VictorN
But to use them properly you must know what they are!
Exactly my point.
Regards,
Paul McKenzie
-
Re: Can someone please run this in XP
Quote:
Originally Posted by
jimJohnson123
the reason i use argc and argv is because it is required
And in my programs I write, I'm also required to use argc and argv in many cases. The difference is that I know what they are used for, and I'm asking if you know what they are used for.
The entire reason for this thread from the start is that you didn't understand what these values are or what their purpose is. The value of argc was causing that message to be printed out, and that again is because the if() statement that you wrote says to print that message if argc <= 1.
I didn't write that if() statement, you wrote it, so it's expected and assumed that you are able to understand what you had written.
Regards,
Paul McKenzie
-
Re: Can someone please run this in XP
What if I changed them to like...
int main(int argc[], char *argv[]){
HANDLE readFile, writeFile;
HANDLE readFileMap, writeFileMap;
PVOID pvreadFile, pvwriteFile;
DWORD readFileSize;
string word = "";
list<string> words;
//VERIFYING ARGUMENTS
if(argc[3]>1)
-
Re: Can someone please run this in XP
Quote:
Originally Posted by
jimJohnson123
What if I changed them to like...
int main(int argc[], char *argv[]){
HANDLE readFile, writeFile;
HANDLE readFileMap, writeFileMap;
PVOID pvreadFile, pvwriteFile;
DWORD readFileSize;
string word = "";
list<string> words;
//VERIFYING ARGUMENTS
if(argc[3]>1)
Did you try to compile it?
-
Re: Can someone please run this in XP
Quote:
Originally Posted by
jimJohnson123
What if I changed them to like...
int main(int argc[], char *argv[]){
You shouldn't be coding blindly and hoping something that works. The main() function has the following signature:
Code:
int main(int argc, char *argv[])
// or
int main()
You cannot change this -- if you did, the code will not compile.
The first parameter is not an array of int, it must be a single int. But I'll ask again, what does argc mean in that parameter list? What is its purpose? Say if argc == 2, what does the "2" mean?
This should be stated clearly in the C++ book that you're using as to the purpose of these two parameters, argc and argv, to the main() function.
Regards,
Paul McKenzie
-
Re: Can someone please run this in XP
Could you at least tell me if im on the right track...i dont need a big explanation if u dont want even a yes or no with this post is fine....
//Test Files -------------------------------------------------------------
char inFilename[] = "C:\\Users\\Bryan\\Documents\\CSI 345\\Palindrome\\Palindrome\\Input.txt";
argv[1] = "C:\\Users\\Bryan\\Documents\\CSI 345\\Palindrome\\Palindrome\\Input.txt";
//--------------------------------------------------------------------------
//VERIFYING ARGUMENTS
if(argc>3)
-
Re: Can someone please run this in XP
Quote:
Originally Posted by
jimJohnson123
Could you at least tell me if im on the right track...i dont need a big explanation if u dont want even a yes or no with this post is fine....
//Test Files -------------------------------------------------------------
char inFilename[] = "C:\\Users\\Bryan\\Documents\\CSI 345\\Palindrome\\Palindrome\\Input.txt";
argv[1] = "C:\\Users\\Bryan\\Documents\\CSI 345\\Palindrome\\Palindrome\\Input.txt";
//--------------------------------------------------------------------------
//VERIFYING ARGUMENTS
if(argc>3)
You still don't seem to know what argc and argv do. Have you even looked at their documentation or checked their values in the debugger? Seems like you'd save yourself a lot of grief if you did.
-
Re: Can someone please run this in XP
1. You do not set argc and argv
2. if you want to use them, you should run from the command prompt
3. If, from the comand prompt, you type:
your_code.exe aaa bbb ccc
then
argc = 4
argv[0] = "your_code.exe"
argv[1] = "aaa"
argv[2] = "bbb"
argv[3] = "ccc"
-
Re: Can someone please run this in XP
Quote:
Originally Posted by
jimJohnson123
Could you at least tell me if im on the right track...i dont need a big explanation if u dont want even a yes or no with this post is fine....
//Test Files -------------------------------------------------------------
char inFilename[] = "C:\\Users\\Bryan\\Documents\\CSI 345\\Palindrome\\Palindrome\\Input.txt";
argv[1] = "C:\\Users\\Bryan\\Documents\\CSI 345\\Palindrome\\Palindrome\\Input.txt";
//--------------------------------------------------------------------------
//VERIFYING ARGUMENTS
if(argc>3)
No.
Thats what you asked for - Was that more helpful than a full explanation?
-
Re: Can someone please run this in XP
well no but i know everyone in the forum has explained this to me as best as they can (which I greatly respect) and still having issues and didnt want to be a burden