b77f [Solved] c++ segfault - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Development > Userland Programming & Scripting

Userland Programming & Scripting C, Shell, Perl, Sed & Awk

Reply
 
Thread Tools Display Modes
  #1  
Old February 12th, 2009, 07:46
graudeejs's Avatar
graudeejs graudeejs is offline
Style(9) Addict
 
Join Date: Nov 2008
Location: Riga, Latvia
Posts: 4,525
Thanks: 422
Thanked 607 Times in 475 Posts
Default c++ segfault

I get segfault at
f s c a n f
i don't understand why i get segfault

input.dat has:
10 Xasdf



sorry, when i write that normal, i get error.

Last edited by graudeejs; December 4th, 2009 at 20:51.
Reply With Quote
  #2  
Old February 12th, 2009, 09:38
anemos's Avatar
anemos anemos is offline
Junior Member
 
Join Date: Nov 2008
Location: Athens, Hellas
Posts: 58
Thanks: 1
Thanked 15 Times in 14 Posts
Default

That's because you haven't allocated space for name.
Either use the new operator or define its size statically i.e. char name[WHATEVER].
Reply With Quote
The Following User Says Thank You to anemos For This Useful Post:
graudeejs (February 12th, 2009)
  #3  
Old February 12th, 2009, 20:46
dap's Avatar
dap dap is offline
Junior Member
 
Join Date: Nov 2008
Posts: 20
Thanks: 5
Thanked 2 Times in 2 Posts
Smile

You should learn about C++ strings and iostreams or stick to C.
Here is a good resource about C++ : http://bruce-eckel.developpez.com/livres/cpp/ticpp/.
__________________
:wq
Reply With Quote
  #4  
Old February 13th, 2009, 00:36
hydra hydra is offline
Member
 
Join Date: Nov 2008
Location: Slovakia
Posts: 272
Thanks: 18
Thanked 24 Times in 21 Posts
Default

I would recommend to start learning C instead of C++
Reply With Quote
  #5  
Old February 13th, 2009, 01:03
fonz's Avatar
fonz fonz is offline
Moderator
 
Join Date: Nov 2008
Location: Apeldoorn, the Netherlands
Posts: 1,472
Thanks: 375
Thanked 241 Times in 214 Posts
Thumbs up

Quote:
Originally Posted by hydra View Post
I would recommend to start learning C instead of C++
Second that!

Alphons (admitting that tastes may differ though)
__________________
Ken sent me.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
test graudeejs Off-Topic 3 February 11th, 2009 10:48
6.4 Release - Bug Already - Didn't Anyone Test It? ter2007 Installing & Upgrading 23 December 7th, 2008 21:03


All times are GMT +1. The time now is 04:29.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0