#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str1[]="ravi kant yadav";
char str2[20],*p1,*p2;
clrscr();
p1=str1+strlen(str1)-1; //Make p1 point to end of str1.
p2=str2;
while(p1>=str1)
*p2++=*p1--;
*p2='\0';
printf("Original string=%s. Reversed String=%s",str1,str2);
getch();
}
The use of the reverse string in C program is used to reverse the letters in the string. An example would be reverse me would be reversed to em esrever.
To reverse a number, first convert the number to a string, then reverse the string. Given your number consists of alphanumeric characters, the number must already be a string so simply reverse the string: #include<string> using std::string; string reverse (const string& s) { string str {}; for (auto c : s) str.insert (str.begin(), c); return str; } int main () { std::cout << "Enter a number: "; string s {}; std::cin >> s; std::cout << "The number in reverse is: " << reverse (s); }
I'd use sprintf (assuming the number wasn't a string already) and pointers. If that's not enough of a clue, you're really not ready to be in this programming class.
addresses
wefwfe
program to find maximum of two numbers using pointers
Assume C#, not C: Traditional way: public string Reverse(string s) { if (string.IsNullOrEmpty(s)) return s; // "" or null char[] characters = s.ToCharArray(); Array.Reverse(characters); return new string(characters); } or as an extension method: public static string Reverse(this string s) { if (s == "") return ""; char[] characters = s.ToCharArray(); Array.Reverse(characters); return new string(characters); } The differences of the 2 methods above is on the caller (how to use Reverse()), and they may co-exist: For example: string test = "abc"; string result1 = Reverse(test); // traditional way string result2 = test.Reverse(); // call the extension
Yes. All string variables are pointers as are other arrays.
yes
Accessing data by address. Some data-structures, like lists and trees, are usually implemented using pointers.
You can either use references or you can simply return the result by value. Note that in C++, unlike C, references are not the same as pointers. C++ references are aliases, alternate names for existing objects, whereas pointers are just variables that may contain a memory address that can be dereferenced.
i don't have any knowledge about your ques. but i guide you to read the "Writing TSR through C" & learn knowledge of FAR & HUGE ponters.by this you can access the adminstrator password using pointers in C.