|
Please be more specific, write what you was able to do so far and what you're not able to accomplish.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hello
Thx for replying
My prob is that i have a file in notepad.I want to call that file in C.That i Know!But my prob is that i hv to use the data in this file for encryption.In fact i want to call a file so as to pass more data.I can read the data in the file but i want to use this data later in my program:i want to know th data_length.But here ion the code i have specified the num of char.But say i dont want to specify.I want my program to count the num of char in my file.Then i want it to encrypt the data.How can i pass those data.How can i store in it in an array.I cn printf the data..but i want to use the data.How can i use that.
FILE *fp;<br />
int noc;<br />
char test[80];<br />
<br />
char ch;<br />
fp = fopen("/TC/MODPROJ/PR1.TXT","r");<br />
<br />
while (1)<br />
{<br />
ch=fgetc(fp);<br />
if (ch==EOF)<br />
break;<br />
noc++;<br />
I am trying to encrypt using a key.The program is working fine when the data is within the code.But i want to call a file.
Please advice
Thanks
NB
|
|
|
|
|
I'm able to understand only a bit of what you wrote. I guess that you need to:
(1) open a text file
(2) Read the file content into a buffer
(3) Encrypt buffer content
(4) (Perhaps) Write the encrypted data to a new file
Now, waht are the steps you're able to do and, on the other hand, what are the problems you're unable to deal with?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Your code snippet likely doesn't work because: 1) you are not initializing noc , and 2) you are doing nothing with ch . Try:
noc = 0;
while (1)
{
ch = fgetc(fp);
if (EOF == ch)
break;
test[noc] = ch;
noc++
} Make sense?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Where exactly do we use function-style casts?
|
|
|
|
|
Regards,
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Or writing a book?
This episode brought to you by the number 5
|
|
|
|
|
Would you like to be a chief editor
|
|
|
|
|
As long as it doesn't require any actual work!
This episode brought to you by the number 5
|
|
|
|
|
check this[^]...
dumb boys never change i see...
|
|
|
|
|
toxcct wrote: dumb boys...
I see no reason to resort to name-calling. If you don't agree with his practices, simply press the "ignore" button.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
http://www.warpspeed.com.au/cgi-bin/inf2html.cmd?..%5Chtml%5Cbook%5CIBMVACPP%5CCPPLNG.INF+184
Though no example but made clear points of how function-style cast behaves in C++.
|
|
|
|
|
Hi : D.
I'm running XP SP2 and Visual C++ 6 SP 6. I'm very curious about why this behavior occurs. If I call this function while I'm debugging, it works!
ExitWindowsEx(EWX_POWEROFF, 0);
But if I run the debug-built or even release-built executables from my hard disk, it does't work! Why!? This is very strange. From the debbuger, the computer starts shut down procedure, but otherwise, no way.
Thank you...
|
|
|
|
|
Hm. Found my own answer in the meantime. Apparently, the VC++ IDE has administrator privileges. If you're a little program like me, check this out:
http://msdn2.microsoft.com/en-us/library/aa376868.aspx (see SE_SHUTDOWN_NAME)
http://msdn2.microsoft.com/en-us/library/aa375202.aspx
...and for a nice example...
http://msdn2.microsoft.com/en-us/library/aa376871.aspx
|
|
|
|
|
Privileges, mon ami, privileges (I suppose...)!
MSDN [^] states
To shut down or restart the system, the calling process must use the AdjustTokenPrivileges function to enable the SE_SHUTDOWN_NAME privilege. For more information, see Running with Special Privileges.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
We replied in the same time : D.
Thank you anyway! Appreciated.
|
|
|
|
|
You hadn't to read the OP.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi!
I m working on a database project in which i use CDaoDatabase class of MFC
to create the connection with a Access .mdb file by using its open()
function. and then use CDaoQueryDef class to save the query in the database.
It works well when I run my program first time for a database but if I
select the another or same Access .mdb file without closing the exe of my project it give error in its open
function. the error msg is somthing like this-> Unhandled exception in
myProject.exe(DAO360.DLL):0xc0000005:Access violation.
Pls help me to solve this problem as early as possible.
Ansh
|
|
|
|
|
Maybe try wrapping methods that can throw exceptions in try/catch blocks.
Then you can get detailed error info.
try
{
...try database open
}
catch (CDaoException *e)
{
... examine exception/error info here
e->Delete();
}
*EDIT* Besides checking for exceptions - are the string pointers you pass to Open() valid?<br />
(Thanks Steve!)
Mark
-- modified at 1:41 Friday 6th July, 2007
Mark Salsbery
Microsoft MVP - Visual C++
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
It looks like the exception was an access violation and so your code will not catch it.
Steve
|
|
|
|
|
Thanks
Mark Salsbery
Microsoft MVP - Visual C++
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
i use try wrapping method bt it unale to track the error.
Acctually wn i debug my program and track all steps then i watch that wn the open function of CDaoDatabase class is called like this->
void CDaoDatabase::Open(LPCTSTR lpszName, BOOL bExclusive,
BOOL bReadOnly, LPCTSTR lpszConnect)
{
----
----
DAO_CHECK(m_pWorkspace->m_pDAOWorkspace->OpenDatabase(
V_BSTR(&var),
COleVariant((long)bExclusive, VT_BOOL),
COleVariant((long)bReadOnly, VT_BOOL),
COleVariant(lpszConnect, VT_BSTRT),
&m_pDAODatabase));
}
and wn the function DAO_CHECK is called it through the exceptions.
Ansh
|
|
|
|
|
What are the values and contents of lpszName and lpszConnect?
Mark
This episode brought to you by the number 5
|
|
|
|
|
lpszName the path of the mdb file is displayed and the lpszConnect stores 0.
Ansh
|
|
|
|
|
aaaan wrote: and the lpszConnect stores 0
I'm not sure a NULL pointer is allowed there.
Instead of 0, try passing _T("")
Mark
This episode brought to you by the number 5
|
|
|
|