• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

C: Dynamic string using variable number of arguments

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.
I need to create dynamic string by given format(%d,%s,%f,%lf,%c) using variable number of arguments in function.
This code gives me an error(main.exe has stopped working):



I assume the error is in functions(itoa,fcvt,ecvt). Thanks for replies.

 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

My! Good grief! What a mass of illegible code. Please post it again without the long lines, with spaces after every comma (in multiple declarations use new lines), and spaces round the binary operators. Break the main() function into smaller functions.
What do you mean about the main function stopping working? Do you suffer a segmentation fault?
What do the different if statements mean? What does pos_int mean when expressed as an int? Does the bang operator ! turn anything non‑zero to 0? How does pos_int differ from *pos_int? Are you using while (pos_int) when you should use while(*pos_int)?
 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic