Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <stdint.h>
- #include <ctype.h>
- #define N 1024
- int check_str(uint8_t *str){
- for (int i=0; i<strlen((char*)str); i++){
- if (isdigit(str[i])>0){
- return 1;
- }
- }
- return 0;
- }
- int main (int argc, char **argv)
- {
- if (argc < 3) {
- printf("Wrong count of params. Usage ./command [file_src_name] [file_dest_name]\n");
- exit(1);
- }
- FILE *fp, *fp2;
- if ((fp = fopen (argv[1], "r")) == NULL)
- {
- printf ("Error open file.\n");
- exit (1);
- }
- if ((fp2 = fopen (argv[2], "w")) == NULL)
- {
- printf ("Error open file.\n");
- exit (1);
- }
- uint8_t buffer[N];
- while(!feof(fp)) {
- memset(buffer, '\0',N);
- if(fgets((char*)buffer, N, fp))
- {
- if (0 == check_str(buffer))
- {
- fputs((char*)buffer, fp2);
- printf("%s", buffer);
- }
- }
- }
- fclose (fp2);
- fclose (fp);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement