Jump to content

Yatharth Shah

Member
  • Posts

    47
  • Joined

  • Last visited

Reputation Activity

  1. Agree
    Yatharth Shah reacted to fordy_rounds in Function in C - Why "malloc( )" required for creating char *   
    C doesn't handle strings well, as you're finding out. Both of these functions have errors, just the first is run-time and the second is compile-time.
    In the first version, you have 
    char * out = malloc(0); which might work with your compiler, but won't necessarily work with any C compiler. (Some compilers return a NULL pointer for malloc(0), which means that you'll get a segmentation fault when you use this in the sprintf call.) The problem is that you're not actually allocating any space here; technically, even though your compiler returns an apparently valid pointer, any use of it (such as in sprintf) is a buffer overflow error. (If you're malloc-ing anything else, you might overwrite it and cause errors.) To fix this, figure out how many chars you'll actually need (some math from the string length will get you there) and malloc that number. (i.e., if strlen returns a two-digit number, you need 6 chars [2 for the first number, 1 for the /, 2 for the second number, and 1 for the null char at the end]; if it's three-digits you need 8, etc.)
    The other issue here is that by malloc-ing a char* and returning it from the function, you're putting the burden of free-ing it onto the calling code, and if that doesn't happen, you could get a memory leak.
     
    Version 2, without the malloc, doesn't work because the pointer is pointing to a read-only string literal. Thus, when you try to change it (with sprintf), there is an error. A fix here is to use the fact that arrays and pointers are closely related, and use 
    char out[16]; This will most probably allocate more characters than you actually need, but that's ok, it's better to have too many than too few. (From my math above, this allows up to a 7-digit number of chars in the original string, or up to 9,999,999 characters. You could adjust the 16 to allow whatever number size you think you'll need; however, it has to be set at compile-time, and cannot by dynamic. If you want it dynamic, you have to malloc it.) This allocates the space onto the stack instead of the heap, which means that it'll automatically be freed without a memory leak.
     
    On a side note, once you know how long "out" can be (whether malloc-ed or statically assigned), you should use snprintf instead of sprintf to ensure there's no buffer overflow. (Example: if I use malloc(4), then try to print "1/10", that's 5 characters, and I've overflowed the allocated space. sprintf will let you do this; snprintf takes the 4 as an argument and will only allow up to 4 chars.)
     
    In summary, here's your answers:
    1) Why does the pointer "out" need to be malloced?
        It doesn't have to be, but that's the only way to get a dynamic array length. If you're ok with a static length, you can use e.g. char out[10]; instead.
    2) Is there a way to write this program without using malloc( ) ?
        Yes, but only with a static array length, as above.
    3) If malloc is used inside the function, how can I free the pointer "out"?
        - I read you should always free any memory allocated with malloc( )
        Yes, that's correct. Since you're returning the pointer, the calling function assumes the responsibility for freeing it. This is messy, and is often the cause of memory leaks. In this case, it might look something like:
    char* output = printerError(myString); // do something else with 'output' free(output);  
  2. Like
    Yatharth Shah got a reaction from gdb123456 in Run code 24/7   
    You can host it on some platform like Heroku.
  3. Like
    Yatharth Shah got a reaction from Symbolls in Python computer vision help i just started out   
    How did you install these modules? Did you pip install it?
  4. Agree
    Yatharth Shah got a reaction from linuxChips2600 in Run code 24/7   
    You can host it on some platform like Heroku.
  5. Like
    Yatharth Shah got a reaction from richodude in Where is the best place to learn to code?   
    Freecodecamp is a great place to learn programming.
  6. Agree
    Yatharth Shah got a reaction from IAmAndre in Indian Government a competitor to the Play Store?   
    This is just taking matters in your own hand. Not too far off.
  7. Informative
    Yatharth Shah got a reaction from thechinchinsong in Google India postponing 30% play store commission until March 31st 2022   
    Summary
    Google has delayed implementation of it's 30%  charge on Play Store transactions in India following reports that leading developers in the country are interested in the creation of a new Android App store. This new policy is being deferred only in India. They are also "setting up Policy Workshops to help clear additional questions about play store policies."
     
    Quotes
     
    My thoughts
    Well, Google is a services company, an the development of a competing service backed by the government is not a good sign, when you have 98% market share, via your Os, and subsequently via your Store. Also, they know that is some market like India will create a Google free Android, it is in their best interests, to consolidate the market. Pixel sales in India, are not impressive compared to the likes of Samsung or Xiaomi, and they would not prefer to miss out on such a huge money maker.
     
    Sources
    https://www.news18.com/news/tech/google-in-india-tale-of-postponed-30-cut-paytm-mini-app-store-delays-dont-hide-big-fault-lines-2934223.html#:~:text=Google is postponing the implementation,Billing Policy to April 2022.&text=The company has delayed the,You grow at our cost.
     
    https://economictimes.indiatimes.com/tech/internet/google-defers-move-to-levy-30-fee-to-april-2022/articleshow/78484208.cms
     
    https://linustechtips.com/main/topic/1253260-indian-government-a-competitor-to-the-play-store/
     
  8. Informative
    Yatharth Shah got a reaction from soldier_ph in Google India postponing 30% play store commission until March 31st 2022   
    Summary
    Google has delayed implementation of it's 30%  charge on Play Store transactions in India following reports that leading developers in the country are interested in the creation of a new Android App store. This new policy is being deferred only in India. They are also "setting up Policy Workshops to help clear additional questions about play store policies."
     
    Quotes
     
    My thoughts
    Well, Google is a services company, an the development of a competing service backed by the government is not a good sign, when you have 98% market share, via your Os, and subsequently via your Store. Also, they know that is some market like India will create a Google free Android, it is in their best interests, to consolidate the market. Pixel sales in India, are not impressive compared to the likes of Samsung or Xiaomi, and they would not prefer to miss out on such a huge money maker.
     
    Sources
    https://www.news18.com/news/tech/google-in-india-tale-of-postponed-30-cut-paytm-mini-app-store-delays-dont-hide-big-fault-lines-2934223.html#:~:text=Google is postponing the implementation,Billing Policy to April 2022.&text=The company has delayed the,You grow at our cost.
     
    https://economictimes.indiatimes.com/tech/internet/google-defers-move-to-levy-30-fee-to-april-2022/articleshow/78484208.cms
     
    https://linustechtips.com/main/topic/1253260-indian-government-a-competitor-to-the-play-store/
     
  9. Informative
    Yatharth Shah got a reaction from BiG StroOnZ in Indian Government a competitor to the Play Store?   
    Summary
    According to a large Indian media Publication, there are rumors that the Government is planning to launch it's own app store as alternative to Google and Apple's app stores. According to the news report, the Ministry of 
    Electronics and Information technology's centre for Development of Advanced Computing (C-DAC) will be responsible for developing it.
     
    Also rumored: It will not take the 30% cut for app hosting.
    Quotes
     
    My thoughts
     India has entered the internet market later than many countries, and is now finding a way to centralize it, and get away from antitrust by taking matters in their own hand. Also, the Govt. has seen the potential for Ai and other emerging fields, and wants to serve as the incubator for such projects, and is thus trying to make it's own market free of US tech giants hands. Also, this means they have more control over the data of their citizens.
     
    Sources
     https://beebom.com/india-may-soon-launch-atmanirbhar-app-store/
    https://www.timesnownews.com/business-economy/industry/article/modi-govt-planning-to-launch-its-own-app-store-as-an-alternative-to-google-apples-app-stores/660806
    https://economictimes.indiatimes.com/tech/internet/india-plans-launch-of-own-app-store-as-alternative-to-google-apple-et-now/articleshow/78424421.cms
  10. Like
    Yatharth Shah got a reaction from Carbonado in Google India postponing 30% play store commission until March 31st 2022   
    Summary
    Google has delayed implementation of it's 30%  charge on Play Store transactions in India following reports that leading developers in the country are interested in the creation of a new Android App store. This new policy is being deferred only in India. They are also "setting up Policy Workshops to help clear additional questions about play store policies."
     
    Quotes
     
    My thoughts
    Well, Google is a services company, an the development of a competing service backed by the government is not a good sign, when you have 98% market share, via your Os, and subsequently via your Store. Also, they know that is some market like India will create a Google free Android, it is in their best interests, to consolidate the market. Pixel sales in India, are not impressive compared to the likes of Samsung or Xiaomi, and they would not prefer to miss out on such a huge money maker.
     
    Sources
    https://www.news18.com/news/tech/google-in-india-tale-of-postponed-30-cut-paytm-mini-app-store-delays-dont-hide-big-fault-lines-2934223.html#:~:text=Google is postponing the implementation,Billing Policy to April 2022.&text=The company has delayed the,You grow at our cost.
     
    https://economictimes.indiatimes.com/tech/internet/google-defers-move-to-levy-30-fee-to-april-2022/articleshow/78484208.cms
     
    https://linustechtips.com/main/topic/1253260-indian-government-a-competitor-to-the-play-store/
     
  11. Informative
    Yatharth Shah got a reaction from bellabichon in Google India postponing 30% play store commission until March 31st 2022   
    Summary
    Google has delayed implementation of it's 30%  charge on Play Store transactions in India following reports that leading developers in the country are interested in the creation of a new Android App store. This new policy is being deferred only in India. They are also "setting up Policy Workshops to help clear additional questions about play store policies."
     
    Quotes
     
    My thoughts
    Well, Google is a services company, an the development of a competing service backed by the government is not a good sign, when you have 98% market share, via your Os, and subsequently via your Store. Also, they know that is some market like India will create a Google free Android, it is in their best interests, to consolidate the market. Pixel sales in India, are not impressive compared to the likes of Samsung or Xiaomi, and they would not prefer to miss out on such a huge money maker.
     
    Sources
    https://www.news18.com/news/tech/google-in-india-tale-of-postponed-30-cut-paytm-mini-app-store-delays-dont-hide-big-fault-lines-2934223.html#:~:text=Google is postponing the implementation,Billing Policy to April 2022.&text=The company has delayed the,You grow at our cost.
     
    https://economictimes.indiatimes.com/tech/internet/google-defers-move-to-levy-30-fee-to-april-2022/articleshow/78484208.cms
     
    https://linustechtips.com/main/topic/1253260-indian-government-a-competitor-to-the-play-store/
     
  12. Funny
    Yatharth Shah reacted to S w a t s o n in Designer makes over $99,000 from iPhone icons in a week   
    Aww the wittle apple fanbois can play with icon packs now. I'm sure they'll get bored of it in a couple years like anyone sane using Android did.
  13. Agree
    Yatharth Shah reacted to Gamer Schnitzel in Indian Government a competitor to the Play Store?   
    India is a rapidly growing economy and has absurd levels of population. Apple is not so stupid to just stop selling their product in India especially considering half the people in silicone valley are Indians.
  14. Like
    Yatharth Shah reacted to Justaphysicsnerd in Indian Government a competitor to the Play Store?   
    Well, As a fellow Indian I think it is more like a political move to garner support for their party, just like D1g1t4L 1ND14 . They won't do anything and even if they do something it will have some security flaws or it will be filled with apps that just want to collect users' private data. As the government has already organized an app building competition for alternative to apps from other countries, I think they will hand out the work to some 3rd party company.
    It is just a dream of the government, that will never come true, unless they build a complete system alternative to android. Like make their own android distro with all their apps, which again the OEMs like Samsung (BTW, If you are not an Indian let me tell ya,  most Indians love samsung), Motorola, Nokia etc. may or may not use. Remember its a free country the government can't force anyone to use their own stuff, that would be like China, where it seems to be a democracy but it is not.
     
     
    PS : If the government really wants to do something, they should first look into improving their internet and digital privacy laws. There are currently no proper laws regarding that in our country.
  15. Agree
    Yatharth Shah got a reaction from LAwLz in Indian Government a competitor to the Play Store?   
    This is just taking matters in your own hand. Not too far off.
  16. Agree
    Yatharth Shah reacted to Shreyas1 in Indian Government a competitor to the Play Store?   
    For everyone saying that Apple will just not sell to India, keep in mind that India is a pretty big potential market for Apple as well. I would assume that Apple would want to expand into India sometime into the future/are currently trying to expand into India (as evidenced by the launch of the new estore for India, albeit with stupidly high prices), so this may give India a bit more leverage than what you would assume based on only the current volume of sales
  17. Informative
    Yatharth Shah got a reaction from Taf the Ghost in Indian Government a competitor to the Play Store?   
    Summary
    According to a large Indian media Publication, there are rumors that the Government is planning to launch it's own app store as alternative to Google and Apple's app stores. According to the news report, the Ministry of 
    Electronics and Information technology's centre for Development of Advanced Computing (C-DAC) will be responsible for developing it.
     
    Also rumored: It will not take the 30% cut for app hosting.
    Quotes
     
    My thoughts
     India has entered the internet market later than many countries, and is now finding a way to centralize it, and get away from antitrust by taking matters in their own hand. Also, the Govt. has seen the potential for Ai and other emerging fields, and wants to serve as the incubator for such projects, and is thus trying to make it's own market free of US tech giants hands. Also, this means they have more control over the data of their citizens.
     
    Sources
     https://beebom.com/india-may-soon-launch-atmanirbhar-app-store/
    https://www.timesnownews.com/business-economy/industry/article/modi-govt-planning-to-launch-its-own-app-store-as-an-alternative-to-google-apples-app-stores/660806
    https://economictimes.indiatimes.com/tech/internet/india-plans-launch-of-own-app-store-as-alternative-to-google-apple-et-now/articleshow/78424421.cms
  18. Informative
    Yatharth Shah got a reaction from admkhalid in Indian Governement to introduce Health ID for Citizens.   
    Summary
     The Prime Minister of India, Mr Narendra Modi in his address to the nation on it's 74th Independence day mentioned the "National Digital Health Mission, due to which every citizen will get  a Health ID, which will store all the medical data of the citizen.
     
    My thoughts
    The Initiative is very good, as it eliminates the chances of health Insurance fraud, and helps keep the medical information of the people in a digitized form and in the government's servers, thus enabling retrieval in case of a disaster and in remote locations, however with every form of Technology, it is susceptible to hacking and Cyber Crime, which raises concern in many people's mind.
     
    Quotes:
     
    Independence Day Speech: National Digital Health Mission is "completely technology-based" initiative that will revolutionise the health sector, the PM said.
     
    Announcing the National Digital Health Mission, Prime Minister Narendra Modi on Saturday said that a unique health ID will be provided to every citizen which will have their details of diseases, diagnostics, report, medication and so on.
     
    Health ID will not be mandatory, as reported by The Print, but the government hopes it will attract more citizens to track health records – digitally – right from birth over the coming years. You don’t need to create files and keep track of older prescriptions. Instead, you can simply click a picture of your reports and add them to Health ID to make digital copies of everything accessible in a jiffy.
     
    The National Health Authority (NHA) has been tasked with the design, roll-out, and the implementation of this mission. This project is currently being piloted in India’s 6 union territories – namely Ladakh, Chandigarh, Dadra and Nagar Haveli and Daman and Diu, Puducherry, Andaman and Nicobar Islands, and Lakshadweep.
     
    Sources
     Press Infromation Bureau India's Twitter post on the subject.
     
    ANI News post
     
    NDTV's coverage of the News
     
    The Print's coverage of the news
     
  19. Informative
    Yatharth Shah got a reaction from thechinchinsong in Indian Governement to introduce Health ID for Citizens.   
    Summary
     The Prime Minister of India, Mr Narendra Modi in his address to the nation on it's 74th Independence day mentioned the "National Digital Health Mission, due to which every citizen will get  a Health ID, which will store all the medical data of the citizen.
     
    My thoughts
    The Initiative is very good, as it eliminates the chances of health Insurance fraud, and helps keep the medical information of the people in a digitized form and in the government's servers, thus enabling retrieval in case of a disaster and in remote locations, however with every form of Technology, it is susceptible to hacking and Cyber Crime, which raises concern in many people's mind.
     
    Quotes:
     
    Independence Day Speech: National Digital Health Mission is "completely technology-based" initiative that will revolutionise the health sector, the PM said.
     
    Announcing the National Digital Health Mission, Prime Minister Narendra Modi on Saturday said that a unique health ID will be provided to every citizen which will have their details of diseases, diagnostics, report, medication and so on.
     
    Health ID will not be mandatory, as reported by The Print, but the government hopes it will attract more citizens to track health records – digitally – right from birth over the coming years. You don’t need to create files and keep track of older prescriptions. Instead, you can simply click a picture of your reports and add them to Health ID to make digital copies of everything accessible in a jiffy.
     
    The National Health Authority (NHA) has been tasked with the design, roll-out, and the implementation of this mission. This project is currently being piloted in India’s 6 union territories – namely Ladakh, Chandigarh, Dadra and Nagar Haveli and Daman and Diu, Puducherry, Andaman and Nicobar Islands, and Lakshadweep.
     
    Sources
     Press Infromation Bureau India's Twitter post on the subject.
     
    ANI News post
     
    NDTV's coverage of the News
     
    The Print's coverage of the news
     
  20. Agree
    Yatharth Shah reacted to Intergalacticbits in Indian Governement to introduce Health ID for Citizens.   
    I think something like this in the USA would be ok but might have pitfalls.
    Like medical records traveling with you is great if you agree with the diagnosis but what if you don't.
    Some doctors won't contradict other doctors I've found in the past with my mother before she past.
    Sometimes you will get a better or more correct diagnosis of the health problem.
    When the doctors at a different hospital in a different city far away from the small town you come from don't have records to look through.
     
    Another concern would be with technology of the day surely at some point being incorporated into the system.
    That your week to week or even day to day health stats might be easily accessible to the system.
    Like the gadgets people wear that collect some health data even now.
    Your health insurance costs could rise as the system becomes more comfortable passing that information to insurance providers over time.
    Data collection is big money. Health data collection could maybe be the next big money business' ?
    How much would I hate it if things got to the point where I couldn't enjoy junk food during the holiday season because big brother health insurance combo will make me pay extra every month for indulging. 😬

    "Oh no Mr Bits you have to pay extra until you get all these numbers back within our guidelines for healthy living."  😲
     
    😁
  21. Agree
    Yatharth Shah reacted to tikker in Python creating a file in the setup   
    It's in the "dist" folder after you run the setup. The tutorial explains how to make the executable: https://www.py2exe.org/index.cgi/Tutorial
    A bit of googline tells there is a "-d" flag to tell the output directory: https://stackoverflow.com/questions/5811960/is-there-a-way-to-specify-the-build-directory-for-py2exe
     
    It is good practise to keep the separate build and dist folders though. That way you can easily track what is just build-time stuff and actual distributable and runnable stuff.
  22. Agree
    Yatharth Shah got a reaction from ColinLTT in Why I Didn't Buy a Tesla   
    Intro felt straight out of a Multi million Hollywood production. @ColinLTT, the drone footage was awesome. 
  23. Like
    Yatharth Shah got a reaction from PrimeMinister in Recommendations for certifications for a career in web development/PC Technician   
    For being a web developer, I would suggest you to just start building projects. It is a better way of learning as it tends to show real problems and also helps you experience common problems firsthand. Start basic, like an online course and build the projects they show in class. Join their communities, it helps very much, as you get to communicate with people doing the same stuff, are on relatively same level and you meet people who have experienced such stuff. I am currently taking Harvard's CS50, and I think it can be a great course for you. It is free and the communities are very helpful.  Also reach out to people whenever struck on some problem.
  24. Agree
    Yatharth Shah reacted to NinJake in Survey: How old is your computer?   
    Old enough for an upgrade, yet not old enough to notice any significant reasons to upgrade.
  25. Informative
    Yatharth Shah reacted to OR13N in How to fix defective pixels in Laptop display?   
    Send it in for RMA and claim your warranty. At least you'll get a good display, at most, you'll get a new laptop.
×