As i mentioned at the title i need to remove 7z word from the zipped folder. If i will create a 7z archive it just looks like this.
If i use n++ to open it it looks like this. Any way to remove just at the start (the other is the folder name inside the zip).
7z¼¯' m® : E†D¶€ 7 z f o l d e r
42
»Ó
Here is the file: https://drive.google.com/open?id=18fpX2DzJkt6j0RqgkwWimu_QR-jT5_Qn
If it's possible from dll's can anyone do and send me(i dont know how)
Thanks
If it's possible to remove first 2 letter without messing the remaining and put it back when it's needed using batch or c i can take that.
Well just making a simple c file works fine.
Code:
#include <stdio.h>
int main(int argc, char *argv[]){
FILE *file;
file=fopen(argv[1],"r+b");
fprintf(file,"text");
}
Btw the text shouldn't be longer than 5 chars or you will corrupt the archive.
For making the archive readable.
Code:
#include <stdio.h>
int main(int argc, char *argv[]){
FILE *file;
file=fopen(argv[1],"r+b");
fprintf(file,"7z¼¯'");
}
Related
I want to make my c++ file read input from one text file and save output in another text file. This is to check my competitive programming questions.
I think this solution works for you.
#include <iostream>
#include <fstream>
//#define cin fin
//#define cout fout
using namespace std;
int main(){
//ofstream fout("output.txt");
//ifstream fin("input.txt");
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
for(int i=0;i<n;i++){
cout<<arr[i]<<endl;
}
return 0;
}
If you want to use as standard input output then you can use as it is. As per your problem you can use it by only removing two slashes(comments).
In the above program "input.txt" is file name for taking input an "output.txt" is the file in which output will be stored.
Note: You only have to provide "input.txt" the program will automatically generate "output.txt".
You can rename "input.txt" and "output.txt" as per your requirement.
If you are not satisfied with the above solution then you can use a program named hightail. Hightail is an automatic tester for programming contest. To know more about hightail and its working click here.
Unclear of what you are asking. Since your question and your description seems asking two different situations.
For your question, you seems to ask how to input a command (like dir or systeminfo) from a file. You can use the function system() in the header file stdlib.h to execute the command read from that file.
For your description, you seems to ask how to input some data from a file to stdin and output to another file, you can look for command redirection, for example Redirect Windows cmd stdout and stderr to a single file.
I'm encountering such a problem. Using Visual Studio 2010, I'd like to add my postb.exe as post-build event action, like this:
postb.exe "$(SolutionDir)" "$(TargetDir)"
My postb.exe is written in C, like this:
#include <stdio.h>
int main(int argc, char **argv)
{
if(argc<3) {
int i;
printf("Need 2 params, only %d given.\n", argc-1);
for(i=1; i<argc; i++)
printf(" argv[%d]=%s\n", i, argv[i]);
return 1;
}
printf("Your .sln dir is: %s\n", argv[1]);
printf("Your .exe dir is: %s\n", argv[2]);
return 0;
}
When the post-build event is fired, I do not get what I'm expecting, like this:
I think the most fatal reason is: Microsoft Visual Studio team decided to terminate $(Solution) and $(TargetDir) with a back-slash. Then the nightmare comes: back-slash inside a CMD shell string acts as an escape character, so the closing quote does not act as closing quote.
I think I have to use quotes(double quotes), because $(Solution) and $(TargetDir) may contain spaces.
I realize I can apply some workaround, e.g., change the post-build event .bat to be:
set var1=$(SolutionDir)
set var2=$(TargetDir)
set var1=%var1:\=/%
set var2=%var2:\=/%
postb.exe "%var1%" "%var2%"
The output becomes usable:
Your .sln dir is: G:/w/test/big job/
Your .exe dir is: G:/w/test/big job/Debug/
But that's a frustrating detour. Is there any best practice for such problem?
If you just want to get rid of the trailing slash you can use a property function, which is already much nicer than the batchfile solution:
"$(SolutionDir.Trim('\'))"
(though as commented: I don't think this is your real problem here)
I would like to write a bash script that runs a .cpp program on a number of text files (I'll henceforth refer to those text files as input files). The .cpp program assumes that there is an input text file in the same directory level called "input.txt". However, the inputs I would like to run through the program are in a sub-directory and there are more than one input txt files that I would like to run through the program.
The input txt files are named using the following convention:
input1.txt, input2.txt, input3.txt, etc,...
They are placed in a folder called "myInputs" which contains text files with similar name e.g., input1.txt.Sol that I'm not interested in.
The commands I would like to have in my script should look in 'myInputs' for txt files of the form: input%.txt where % may be a number. For each file of that form, the script should print out the name of the file on a line-by-line basis. i.e., input1.txt should be on its own line, input2.txt should be on it own line.
Any tip is appreciated!
There is a bash command called find
http://unixhelp.ed.ac.uk/CGI/man-cgi?find
#include <stdio.h>
#include <stdlib.h>
int main( int argc, char *argv[] ) {
(void)system( "find \"MyInputs\" \"input*.txt\"" );
/* whatever comes next */
return 0;
}
Unfortunately, I don't know that much C++, but here's a snippet in C
This is not a code question but an Xcode IDE question.
For those who pride themselves in code analysis, that's good, but in this case, please try to focus on the question in the Title above not the code.
In the Xcode IDE I created a new project and selected a "Command Line Tool" creating ReadAFile.
I then entered some simple code into main.c to read and display the contents of "Data.txt".
I then selected File, New, File, and selected Empty (For an empty document) and named it Data.txt and then I typed out a sentence then saved the file.
In Xcode, when I choose Product, Run, I get the following error:
Error while opening the file.
: No such file or directory
Program ended with exit code: 1
Where do I set the Xcode IDE property so that it knows where my data file is to avoid getting the "No such file or directory" error?
When I enter the very same code into ReadAFile.c and I type out the very same file "Data.txt" at a terminal prompt using vim, save it, and run make ReadAFile, the code executes properly.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, const char * argv[]) {
char ch, file_name[25];
FILE *fp;
strcpy(file_name,"Data.txt");
fp = fopen(file_name,"r");
if( fp == NULL ) {
perror("Error while opening the file.\n");
exit(EXIT_FAILURE);
}
printf("The contents of %s file are :\n", file_name);
while( ( ch = fgetc(fp) ) != EOF )
printf("%c",ch);
fclose(fp);
return 0;
}
That's a good question... I have a temporary, work around, answer...
I do respect your request to focusing on the question rather than your code.
As a quick temporary answer, the only answer I have for you at this point is to modify your code, for now, if you are only debugging your code along with your data file. I know hard coding your file locations is a no-no but for debugging purposes the following will get you over this bump in your road. You can try to hard code the directory location along with your data file so that your code can find it. For example, let's say that your Users directory on your Mac is jerryletter, you could copy your Data.txt file to your Users directory ~/jerryletter. Then could modify just one line of your code like the following:
"strcpy(file_name,"/Users/jerryletter/Data.txt");"
DougPan.com
I have some legacy data that was created on Windows XP. It contains absolute file names to files in users' My Documents directories. On Windows 7, these absolute references are no longer point to the correct place. For example what was "C:\Documents and Settings\Gareth\My Documents\readme.txt" should now be "C:\Users\Gareth\Documents\readme.txt".
Many Win32 functions are happy to take the file names under "C:\Documents and Settings" and to behind the scenes convert them to the new file names, however there are functions we use that don't do this. Is there a Windows API that I can use to convert these file names to the new locations?
Obviously, I could do string search and replace, but that wouldn't be guaranteed to work under all circumstances. Because there are Windows functions that seem to do the substitution it feels like there ought to be a published function I can call to do the same thing.
Just to clarify my question: I'm looking for a function that does this:
Input: "C:\Documents and Settings\Gareth\My Documents\readme.txt"
Output: "C:\Users\Gareth\Documents\readme.txt"
or
Input: "C:\Documents and Settings\Gareth\My Documents\"
Output: "C:\Users\Gareth\Documents\"
This works with symbolic links. That should work on any function that takes a path, MSDN documentation is here: msdn.microsoft.com/en-us/library/aa365680%28v=VS.85%29.aspx
I verified MapFileAndCheckSum(), it works fine. Windows7, compiled with UNICODE in effect.
#include "stdafx.h"
#include <windows.h>
#include <assert.h>
#include <imagehlp.h>
#pragma comment(lib, "imagehlp.lib")
int _tmain(int argc, _TCHAR* argv[])
{
DWORD hdrsum, chksum;
const wchar_t* path = L"c:\\documents and settings\\hpassant\\my documents\\test.exe";
DWORD retval = MapFileAndCheckSum(path, &hdrsum, &chksum);
assert(retval == 0);
return 0;
}
Is it what you need?
%USERPROFILE%\My Documents
I'm not sure where exactly you're using this (and it's been a while since I've used Windows), but I remember being able to use the %HOMEPATH% variable to get the current user's Documents & Settings directory: \Documents and Settings{username}. I think that this works with the updated Windows 7 paths, too.