Remove spaces in batch variable [closed] - batch-file

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
So I have these two variables, a and c, they both have a space after them so when I'm trying to join them it prints "a c " and not "ac". How should I go on about removing the spaces?

set "a=%a: =%"
is one way. set the variable=%variablename:stringtoreplace=replacementstring%
The quotes ensure that any trailing spaces in the set line are not included into the value assigned.
The replacement string may be empty.
This is a general solution, replacing all strings matching stringtoreplace with the defined replacement.

Related

Printing space between strings when using strcat() function [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
How to print a space between two strings using strcat() function in c language?
You can do something like this.
strcat(string1, " ");
strcat(string1, string2);
or, just in one line.
strcat(strcat(string1, " "),string2)
Both the snippets are actually same!

How to read multiple lines in string until specified character in C [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Need to read everything until say *** comes up:
Input:
Hey there
how are
you
***
Output:
Hey there
how are
you
Would have used scanf("%[^***]s) but can't read all lines at once.
Only having basic C knowledge
The way I would do this is read one line at a time (with a funcion such as fgets instead of scanf) and then see if the line that you last read is equal to ***. You can use use strcmp to do that but you can also do it by hand if you are not allowed to use strcmp for some reason.

How can i add blank space inside printf in c programming? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I want to add two blank space inside c programming print statement. I have try but it always count one single space. How can i add another one ?? If i use \t then it count 4 space as set.
printf("Hello Dhaka!");
printf("Hello Dhaka!"); adds 2 spaces, since it contains 2 spaces.
The problem must be related to your output. Perhaps the console uses some strange font that is not fixed-width.

Character functions vs string functions [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I just found a short code here, which would detect blank lines in a file. It used fgets() function in C library.
I wonder if character functions are better suited for files which have tabs, and perhaps continous spaces.
My qustion is what is the best way to parse a file for blank lines?
You can also use scanf(" %[^\n]s",string); in order to read spaces but fgets is best solution for your case.

string equals or substring search [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Is there any function in C, that will find string exactly same as string , if there is no exact form, return first string that contains substring?
or i have to use first binary search for exact form, and then linear for substing
Under string.h,
strcmp(str1,str2); - returns 0 if strings are same, returns the difference between the strings if they are not same.
strstr(str1,str2); - finds whether str2 is a substring of str1.
You may want to use these two library functions and write the required logic.

Resources