[Solved] this c program is not giving correct output.(to convert number string to integer) [duplicate]

The problem is near break statement, Your break statement is being executed without executing a++;. Here is the correct code. #include<stdio.h> #include<string.h> void main() { int a=0, copy[10]={0},len,i; char string[10]; clrscr(); puts(“enter a number string”); gets(string); len=strlen(string); while(a<len) { for(i=48;i<=57;i++) { if(string[a]==i) { copy[a]=i-48; a++; break; } } } for(i=0;i<len;i++) printf(“%d”,copy[i]); getch(); } solved this … Read more

[Solved] Convert.ToInt32(“example”) Collisions? [closed]

No, Convert.ToInt32(text) will just try to parse your text to an int, like: Convert.ToInt32(“032”) will return 32 as int but Convert.ToInt32(“Brian”) will throw an exception. I assume that you want to have some kind of hashing, when you say “different words to the same int”. Try GetHashCode(). It will return the same value if you … Read more

[Solved] C++ read large text file [closed]

The most efficient method is to read blocks or chunks of data into a buffer than scan the buffer. The I/O has an overhead cost and the more data you can fetch per request, the better. Searching in memory is always faster than reading one character at a time from the input. Be aware of … Read more

[Solved] Implementing / enforcing wraparound arithmetic in C [closed]

Signed overflow is undefined. Unsigned overflow wraps. Implementing signed wraparound arithmetic is mostly a matter of doing everything in unsigned math. There are a few things to be careful about, though: unsigned short and unsigned char arithmetic works by converting the operands to either int or unsigned int first. Usually int, unless you’re on a … Read more

[Solved] Unsigned int not working C++

You are expecting the cast from int to unsigned int to simply change the sign of a negative value while maintaining its magnitude. But that isn’t how it works in C or C++. when it comes to overflow, unsigned integers follow modular arithmetic, meaning that assigning or initializing from negatives values such as -1 or … Read more

[Solved] C++ code is wrong

Use google. In C++ you must define a type of variable. Look for a C++ tutorial, there are many of them. Use google. 1 solved C++ code is wrong

[Solved] Use Enum values as Properties in

I’m not sure what is your question, but as @crashmstr commented .. it seems you don’t need an Enum but you just need a class to hold these properties Any way you can use this BUT IT’S NOT A GOOD PRACTICE and I don’t know what do you want the setter to do public string … Read more

[Solved] C – How can a pointer overwrite a local const block of memory but not the global const block of memory?

It is completely up to the implementation. For example, const data on bare metal ARM uCs is stored in the FLASH memory. You can write to there but it will have no effect at all. Hosted systems will behave differently depending on the OS, its version and hardware. How can I overwrite a const block … Read more

[Solved] Check if the string contains all the characters from a to z [closed]

You can use an extension method like this public static class StringExtensions { private static char[] _alphabet; static StringExtensions() { _alphabet = “abcdefghijklmnopqrstuvwxyz”.ToCharArray(); } public static bool ContainsAlphabet(this string input) { return !_alphabet .Except(new HashSet<char>(input)) .Any(); } } “asdasd”.ContainsAlphabet(); //false “abcdeffffghijklmnopqrstuvwxyzzz”.ContainsAlphabet(); //true 0 solved Check if the string contains all the characters from a to … Read more